[OpenTelemetry] Help diagnose dropped traces#7427
Conversation
- 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 Report❌ Patch coverage is
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Add PR number.
There was a problem hiding this comment.
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-SdkEventSource 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.
- 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 |
There was a problem hiding this comment.
Shouldn't it by just?
| `AddSource("Microsoft.AspNetCore.Hosting")`. The request activity then becomes | |
| `AddSource("Microsoft.AspNetCore")`. The request activity then becomes |
There was a problem hiding this comment.
I'm checking in the ASP.NET Core source, but it's definitely Microsoft.AspNetCore.Hosting for metrics: source
There was a problem hiding this comment.
You're right that for tracing it's Microsoft.AspNetCore: source
There was a problem hiding this comment.
Of course I should have just looked in the other repo first... code 😅
Fix activity source name for ASP.NET Core.
55a25ea
Fixes #7426
Changes
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)