Skip to content

[AspNetCore] Avoid adding tags for traces#3993

Merged
martincostello merged 19 commits intoopen-telemetry:mainfrom
martincostello:aspnetcore-avoid-tags-where-possible
Apr 30, 2026
Merged

[AspNetCore] Avoid adding tags for traces#3993
martincostello merged 19 commits intoopen-telemetry:mainfrom
martincostello:aspnetcore-avoid-tags-where-possible

Conversation

@martincostello
Copy link
Copy Markdown
Member

See martincostello#2 (review).

Relates to #3808.

Changes

Avoid adding tags for ASP.NET Core activities where ASP.NET Core has native support to add them itself.

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)

Avoid adding tags for ASP.NET Core activities where ASP.NET Core has native support to add them itself.
@github-actions github-actions Bot added the comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore label Mar 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.99%. Comparing base (dc7e36a) to head (42d6789).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3993      +/-   ##
==========================================
+ Coverage   75.92%   75.99%   +0.06%     
==========================================
  Files         466      466              
  Lines       18631    18635       +4     
==========================================
+ Hits        14146    14161      +15     
+ Misses       4485     4474      -11     
Flag Coverage Δ
unittests-Instrumentation.AspNet 76.99% <ø> (ø)
unittests-Instrumentation.AspNetCore 70.79% <100.00%> (+0.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...umentation.AspNetCore/AspNetCoreInstrumentation.cs 100.00% <100.00%> (ø)
...eInstrumentationTracerProviderBuilderExtensions.cs 95.55% <100.00%> (-0.19%) ⬇️
...tation.AspNetCore/Implementation/HttpInListener.cs 74.50% <100.00%> (+1.22%) ⬆️

... and 4 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.

Add CHANGELOG entry.
Fix markdown lint warnings.
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
@martincostello martincostello requested a review from a team March 19, 2026 14:13
@martincostello martincostello marked this pull request as ready for review March 27, 2026 15:03
Copilot AI review requested due to automatic review settings March 27, 2026 15:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates ASP.NET Core tracing instrumentation to avoid setting certain HTTP semantic-convention tags when ASP.NET Core can provide them natively (targeting improved performance on newer runtimes).

Changes:

  • Add runtime/app-context gating to skip setting selected HTTP tags when ASP.NET Core native OpenTelemetry data is enabled.
  • Refactor event handling and small code-style cleanups in instrumentation wiring.
  • Document the behavior and the relevant AppContext switch in the AspNetCore instrumentation changelog.

Reviewed changes

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

File Description
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Adds .NET 10 gating + AppContext switch check to conditionally avoid manual tag population.
src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md Documents the new behavior and the AppContext switch guidance.
src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationTracerProviderBuilderExtensions.cs Minor formatting/comment wording updates.
src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentation.cs Minor lambda/dispose style cleanup.

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

Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Fix CHANGELOG and comment.
Fix incorrect pattern matching on non-nullable `PathString`.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions Bot added the Stale label Apr 6, 2026
@martincostello martincostello added keep-open Prevents issues and pull requests being closed as stale and removed Stale labels Apr 6, 2026
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md Outdated
Remove trailing space.
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md Outdated
Still needs a line between entries.
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Update `IsOpenTelemetryActivityDataSuppressed()` to be aware of .NET 11.
- Add a test that validates the activity tags are set regardless of the feature toggle's value.
- Remove redundant use of `#if NET` from tests as we don't support .NET Framework anymore.
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Update comment.

Co-authored-by: Piotr Kiełkowicz <pkiekowicz@splunk.com>
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Invert the meaning of the flag.
Clarify the comment for .NET 10.
Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Fix missing words.
@martincostello martincostello added this pull request to the merge queue Apr 30, 2026
Merged via the queue into open-telemetry:main with commit fd2c666 Apr 30, 2026
70 checks passed
@martincostello martincostello deleted the aspnetcore-avoid-tags-where-possible branch April 30, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore keep-open Prevents issues and pull requests being closed as stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants