Skip to content

Conversation

@markushi
Copy link
Member

@markushi markushi commented Oct 21, 2025

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:

@markushi markushi requested review from Copilot and removed request for Flash0ver and jamescrosswell October 21, 2025 12:08
@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 1d25c56

Copy link

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

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 W3CTraceparentHeader class that formats trace information according to the W3C Trace Context specification
  • Adds a PropagateTraceparent configuration 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.

@bruno-garcia
Copy link
Member

@sentry review

@bitsandfoxes bitsandfoxes force-pushed the feat/w3c-traceparent-support branch from e0256b2 to 0a0945a Compare October 21, 2025 12:56
@bitsandfoxes bitsandfoxes changed the base branch from main to version6 October 21, 2025 12:56
@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (version6@e7d6b84). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/Sentry/Extensibility/DisabledHub.cs 0.00% 1 Missing ⚠️
src/Sentry/Extensibility/HubAdapter.cs 0.00% 1 Missing ⚠️
src/Sentry/SentryMessageHandler.cs 87.50% 0 Missing and 1 partial ⚠️
src/Sentry/SentrySdk.cs 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

/// 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"/>
Copy link
Collaborator

@jamescrosswell jamescrosswell Oct 21, 2025

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.

Copy link
Collaborator

@jamescrosswell jamescrosswell left a 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 !

@markushi markushi merged commit aedce04 into version6 Oct 22, 2025
30 checks passed
@markushi markushi deleted the feat/w3c-traceparent-support branch October 22, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants