Skip to content

[Instrumentation.AspNetCore] Fix missing grpc.method tag when empty tracestate header is present#4503

Closed
chinmaychahar wants to merge 1 commit into
open-telemetry:mainfrom
chinmaychahar:main
Closed

[Instrumentation.AspNetCore] Fix missing grpc.method tag when empty tracestate header is present#4503
chinmaychahar wants to merge 1 commit into
open-telemetry:mainfrom
chinmaychahar:main

Conversation

@chinmaychahar

Copy link
Copy Markdown

Fixes #4501

Changes

Normalize null and empty string TraceState comparison in HttpInListener.OnStartActivity to prevent sibling activity creation when an empty tracestate: header is present.

The .NET runtime's W3CPropagator sets activity.TraceStateString = null for an empty tracestate header, while OpenTelemetry's CompositeTextMapPropagator extracts TraceState = "". Both represent absent tracestate but== comparison treats them as different, triggering unnecessary sibling activity creation.

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)

@chinmaychahar
chinmaychahar requested a review from a team as a code owner June 12, 2026 08:42
@chinmaychahar chinmaychahar changed the title Fix missing grpc.method tag when empty tracestate header is present (… Fix missing grpc.method tag when empty tracestate header is present Jun 12, 2026
@github-actions github-actions Bot added the comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore label Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.86%. Comparing base (d2cb84e) to head (537ffd7).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4503   +/-   ##
=======================================
  Coverage   75.86%   75.86%           
=======================================
  Files         438      438           
  Lines       18002    18002           
=======================================
  Hits        13657    13657           
  Misses       4345     4345           
Flag Coverage Δ
unittests-Instrumentation.AspNet 77.50% <ø> (ø)
unittests-Instrumentation.AspNetCore 87.34% <100.00%> (ø)

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

Files with missing lines Coverage Δ
...tation.AspNetCore/Implementation/HttpInListener.cs 87.07% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Kielek Kielek changed the title Fix missing grpc.method tag when empty tracestate header is present [Instrumentation.AspNetCore] Fix missing grpc.method tag when empty tracestate header is present Jun 12, 2026
@Kielek

Kielek commented Jun 12, 2026

Copy link
Copy Markdown
Member

I think that it should be handled in this way open-telemetry/opentelemetry-dotnet#7407

@chinmaychahar

Copy link
Copy Markdown
Author

Thanks @Kielek! That's a cleaner fix. Since #7407 is already merged, should I close this PR?

@chinmaychahar chinmaychahar closed this by deleting the head repository Jun 13, 2026
@Kielek

Kielek commented Jun 15, 2026

Copy link
Copy Markdown
Member

@chinmaychahar, closing this PR makes sense to me. The issue will be after next OTel SDK release.
We have made it last week, so it takes some time. If the fix is urgent, you can consider reopening here and make this fix local.
Instrumentation packages are released usually on demand.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] gRPC server spans do not contain grpc.method tag when empty tracestate header is present

2 participants