-
-
Notifications
You must be signed in to change notification settings - Fork 225
feat: Add support for w3c trace parent headers for outgoing requests #4661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for W3C Trace Context traceparent headers in outgoing HTTP requests to enable interoperability with OpenTelemetry-compliant distributed tracing systems.
Key Changes:
- Introduces a new
W3CTraceparentHeaderclass that formats trace information according to the W3C Trace Context specification - Adds a
PropagateTraceparentconfiguration option (default:false) to control whether traceparent headers are sent - Implements
GetTraceparentHeader()method across the Hub interface hierarchy to retrieve traceparent information from active spans or propagation context
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Sentry/W3CTraceparentHeader.cs |
New class implementing W3C traceparent header formatting |
src/Sentry/SentryOptions.cs |
Adds PropagateTraceparent configuration option |
src/Sentry/SentryMessageHandler.cs |
Adds logic to attach traceparent headers to outgoing HTTP requests |
src/Sentry/Internal/Hub.cs |
Implements GetTraceparentHeader() to construct headers from spans or propagation context |
src/Sentry/IHub.cs |
Adds GetTraceparentHeader() to the Hub interface |
src/Sentry/SentrySdk.cs |
Exposes static GetTraceparentHeader() method |
src/Sentry/Extensibility/HubAdapter.cs |
Forwards GetTraceparentHeader() calls to SentrySdk |
src/Sentry/Extensibility/DisabledHub.cs |
Returns null for GetTraceparentHeader() when hub is disabled |
test/Sentry.Tests/Protocol/W3CTraceparentHeaderTests.cs |
Comprehensive test coverage for W3CTraceparentHeader class |
test/Sentry.Tests/HubTests.cs |
Tests for Hub's GetTraceparentHeader() implementation |
test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt |
Updates API surface approval snapshot |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@sentry review |
e0256b2 to
0a0945a
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## version6 #4661 +/- ##
===========================================
Coverage ? 73.16%
===========================================
Files ? 480
Lines ? 17354
Branches ? 3424
===========================================
Hits ? 12697
Misses ? 3807
Partials ? 850 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| /// The default value is <c>false</c>. Set to <c>true</c> to enable W3C Trace Context propagation | ||
| /// for interoperability with services that support OpenTelemetry standards. | ||
| /// </remarks> | ||
| /// <seealso href="https://develop.sentry.dev/sdk/telemetry/traces/#propagatetraceparent"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably document this in a more "SDK User" friendly format... I added #4663 as a follow up for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from the redundant = false assignment on the property, that CoPilot mentioned.
Thanks @markushi !
Co-authored-by: Copilot <[email protected]>
Implements #4505
Note: this isn't the same as the reverted PR below because that's about incoming requests, while this is about outgoing requests: