Skip to content

[Infra] Add banned API analyzers#4131

Merged
martincostello merged 3 commits into
open-telemetry:mainfrom
martincostello:add-banned-api-analyzers
Apr 17, 2026
Merged

[Infra] Add banned API analyzers#4131
martincostello merged 3 commits into
open-telemetry:mainfrom
martincostello:add-banned-api-analyzers

Conversation

@martincostello

@martincostello martincostello commented Apr 16, 2026

Copy link
Copy Markdown
Member

Changes

Add analyzers to prevent use of .NET APIs in production code that have preferred alternatives.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Add analyzers to prevent use of .NET APIs in production code that have preferred alternatives.
@github-actions github-actions Bot added infra Infra work - CI/CD, code coverage, linters dependencies Pull requests that update a dependency file labels Apr 16, 2026
@codecov

codecov Bot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.69%. Comparing base (304b93c) to head (7488712).
⚠️ Report is 8 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4131      +/-   ##
==========================================
- Coverage   72.89%   72.69%   -0.20%     
==========================================
  Files         460      468       +8     
  Lines       18213    18256      +43     
==========================================
- Hits        13276    13271       -5     
- Misses       4937     4985      +48     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 89.95% <ø> (ø)
unittests-Exporter.Geneva 54.70% <ø> (-0.14%) ⬇️
unittests-Exporter.InfluxDB 95.81% <ø> (ø)
unittests-Exporter.Instana 74.86% <ø> (ø)
unittests-Exporter.OneCollector 94.61% <ø> (ø)
unittests-Extensions 90.78% <ø> (+0.04%) ⬆️
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Extensions.Enrichment.AspNetCore 86.27% <ø> (ø)
unittests-Extensions.Enrichment.Http 94.33% <ø> (ø)
unittests-Instrumentation.AWS 83.54% <ø> (ø)
unittests-Instrumentation.AspNet 76.61% <ø> (ø)
unittests-Instrumentation.AspNetCore 70.44% <ø> (ø)
unittests-Instrumentation.Cassandra 23.52% <ø> (?)
unittests-Instrumentation.ConfluentKafka 39.83% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.60% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 80.80% <ø> (ø)
unittests-Instrumentation.EventCounters 77.27% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.42% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 73.78% <ø> (ø)
unittests-Instrumentation.Hangfire 86.05% <ø> (ø)
unittests-Instrumentation.Http 74.62% <ø> (ø)
unittests-Instrumentation.Owin 88.62% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 78.76% <ø> (ø)
unittests-Instrumentation.Remoting 64.28% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 34.68% <ø> (ø)
unittests-Instrumentation.SqlClient 85.21% <ø> (ø)
unittests-Instrumentation.StackExchangeRedis 71.98% <ø> (ø)
unittests-Instrumentation.Wcf 79.68% <ø> (ø)
unittests-OpAmp.Client 78.57% <ø> (-0.46%) ⬇️
unittests-PersistentStorage 68.19% <ø> (-0.66%) ⬇️
unittests-Resources.AWS 73.88% <ø> (ø)
unittests-Resources.Azure 88.31% <ø> (ø)
unittests-Resources.Container 67.34% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)
unittests-Resources.Host 72.26% <ø> (ø)
unittests-Resources.OperatingSystem 76.98% <ø> (ø)
unittests-Resources.Process 100.00% <ø> (ø)
unittests-Resources.ProcessRuntime 79.59% <ø> (ø)
unittests-Sampler.AWS 93.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello
martincostello marked this pull request as ready for review April 16, 2026 12:50
@martincostello
martincostello requested a review from a team as a code owner April 16, 2026 12:50
Copilot AI review requested due to automatic review settings April 16, 2026 12:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds infrastructure-level banned API enforcement for production projects to steer usage toward preferred HTTP helper patterns.

Changes:

  • Add Microsoft.CodeAnalysis.BannedApiAnalyzers as a global analyzer package reference.
  • Introduce build/BannedSymbols.txt and wire it into production builds via Common.prod.props.
  • Include the new banned-symbols file in the solution items.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
opentelemetry-dotnet-contrib.slnx Adds build/BannedSymbols.txt to solution items for visibility/editing.
build/Common.prod.props Registers BannedSymbols.txt as an AdditionalFiles input for analyzers in production builds.
build/BannedSymbols.txt Defines banned .NET HTTP APIs and suggested alternatives.
Directory.Packages.props Adds global reference to Microsoft.CodeAnalysis.BannedApiAnalyzers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build/BannedSymbols.txt Outdated
Comment thread build/BannedSymbols.txt Outdated
Comment thread build/BannedSymbols.txt Outdated
Fix incorrect method signatures.
@martincostello
martincostello added this pull request to the merge queue Apr 17, 2026
Merged via the queue into open-telemetry:main with commit 09f26f5 Apr 17, 2026
328 of 329 checks passed
@martincostello
martincostello deleted the add-banned-api-analyzers branch April 17, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file infra Infra work - CI/CD, code coverage, linters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants