Skip to content

[OpenTelemetry] Help diagnose dropped traces#7427

Merged
martincostello merged 7 commits into
open-telemetry:mainfrom
martincostello:gh-7426
Jun 25, 2026
Merged

[OpenTelemetry] Help diagnose dropped traces#7427
martincostello merged 7 commits into
open-telemetry:mainfrom
martincostello:gh-7426

Conversation

@martincostello

Copy link
Copy Markdown
Member

Fixes #7426

Changes

  • Add diagnostic event when an activity is dropped due to the local parent not being sampled.
  • Cover the scenario in the troubleshooting guide.

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 diagnostic event when an activity is dropped dur to the local parent not being sampled.
- Cover the scenario in the troubleshooting guide.

Resolves open-telemetry#7426.
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.00%. Comparing base (2f02a19) to head (1e17e9d).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/OpenTelemetry/Trace/TracerProviderSdk.cs 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7427      +/-   ##
==========================================
- Coverage   90.01%   90.00%   -0.02%     
==========================================
  Files         277      277              
  Lines       14642    14653      +11     
==========================================
+ Hits        13180    13188       +8     
- Misses       1462     1465       +3     
Flag Coverage Δ
unittests-Project-Experimental 89.85% <90.90%> (-0.09%) ⬇️
unittests-Project-Stable 89.79% <90.90%> (-0.19%) ⬇️

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

Files with missing lines Coverage Δ
...nTelemetry/Internal/OpenTelemetrySdkEventSource.cs 67.01% <100.00%> (+1.45%) ⬆️
src/OpenTelemetry/Trace/TracerProviderSdk.cs 99.04% <75.00%> (-0.32%) ⬇️

... and 4 files with indirect coverage changes

Comment thread src/OpenTelemetry/CHANGELOG.md Outdated

@joaopgrassi joaopgrassi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome, that would have saved me some hours (and tokens, lol). Thank you!

@martincostello
martincostello marked this pull request as ready for review June 19, 2026 12:54
@martincostello
martincostello requested a review from a team as a code owner June 19, 2026 12:54
Copilot AI review requested due to automatic review settings June 24, 2026 10:42

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 self-diagnostics and documentation to help users understand why their custom spans/activities may not be exported when they have an in-process (local) parent that is not recorded, which commonly happens in ASP.NET Core scenarios without registering the framework ActivitySource.

Changes:

  • Emit a new verbose OpenTelemetry-Sdk EventSource event when an activity is dropped due to an unsampled local parent.
  • Add unit tests validating when the diagnostic event is (and is not) emitted.
  • Document the scenario and mitigation options in the tracing troubleshooting guide.

Reviewed changes

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

File Description
src/OpenTelemetry/Trace/TracerProviderSdk.cs Emits the new self-diagnostics event when sampling drops an activity.
src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs Adds the new EventSource event (ID 58) and a guarded helper to emit it only for unsampled local parents.
test/OpenTelemetry.Tests/Trace/TracerProviderSdkTests.cs Adds tests covering local-unsampled-parent emission and remote-parent non-emission.
docs/trace/customizing-the-sdk/README.md Adds troubleshooting guidance for spans dropped due to an unsampled parent in common ASP.NET Core setups.

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

Comment thread src/OpenTelemetry/Trace/TracerProviderSdk.cs Outdated
Comment thread src/OpenTelemetry/Trace/TracerProviderSdk.cs
Comment thread src/OpenTelemetry/CHANGELOG.md Outdated
Comment thread docs/trace/customizing-the-sdk/README.md Outdated
- Update condition for when to log.
- Fix typos.
[ASP.NET Core
instrumentation package](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/tree/main/src/OpenTelemetry.Instrumentation.AspNetCore)
(`AddAspNetCoreInstrumentation()`), or at minimum register the source with
`AddSource("Microsoft.AspNetCore.Hosting")`. The request activity then becomes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't it by just?

Suggested change
`AddSource("Microsoft.AspNetCore.Hosting")`. The request activity then becomes
`AddSource("Microsoft.AspNetCore")`. The request activity then becomes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm checking in the ASP.NET Core source, but it's definitely Microsoft.AspNetCore.Hosting for metrics: source

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right that for tracing it's Microsoft.AspNetCore: source

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Of course I should have just looked in the other repo first... code 😅

Comment thread docs/trace/customizing-the-sdk/README.md Outdated
Fix activity source name for ASP.NET Core.
@martincostello
martincostello enabled auto-merge June 24, 2026 14:52
@martincostello
martincostello added this pull request to the merge queue Jun 25, 2026
Merged via the queue into open-telemetry:main with commit 55a25ea Jun 25, 2026
140 of 142 checks passed
@martincostello
martincostello deleted the gh-7426 branch June 25, 2026 05:35
@martincostello martincostello added this to the v1.17.0 milestone Jul 3, 2026
This was referenced Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation related pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Custom activities silently dropped when not calling AddAspNetCoreInstrumentation

4 participants