Skip to content

[Breaking change]: Switch the default trace context propagator from Legacy to W3C #45793

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

Open
1 of 3 tasks
tarekgh opened this issue Apr 12, 2025 · 3 comments
Open
1 of 3 tasks
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 10 Work items for the .NET 10 release

Comments

@tarekgh
Copy link
Member

tarekgh commented Apr 12, 2025

Description

DistributedContextPropagator is the type used to encode trace context and baggage values for propagation across process/machine boundaries. Historically, .NET used a legacy propagator as the default, which propagated baggage using the Correlation-Context header name. However, this legacy propagator is not fully compliant with the W3C Trace Context and Baggage specifications.

Starting with .NET 10, we are adopting the W3C propagator as the default. The new W3C propagator differs from the legacy one in several key ways:

  • It uses the baggage header name instead of Correlation-Context to propagate baggage.
  • It propagates only W3C-formatted trace parent IDs, whereas the legacy propagator can handle older hierarchical IDs.
  • It enforces W3C-compliant encoding for trace parent, trace state, and baggage keys and values. The legacy propagator is more lenient and does not enforce strict formatting.

dotnet/runtime#114583
dotnet/runtime#114584

Version

.NET 10

Previous behavior

DistributedContextPropagator.CreateDefaultPropagator() was returning instance of the legacy propagator and by default DistributedContextPropagator.Current was set to that legacy instance.

New behavior

DistributedContextPropagator.CreateDefaultPropagator() will return instance of the W3C propagator and by default DistributedContextPropagator.Current will be set to that W3C instance.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

This change is to fully comply with the W3C specification for propagating the trace context and baggage.

Recommended action

In .NET, we are exposing a new API DistributedContextPropagator.CreatePreW3CPropagator() to allow retrieve the legacy propagator instance to use if want to get the old behavior. Users can do the following to get the old behavior.

DistributedContextPropagator.Current = DistributedContextPropagator.CreatePreW3CPropagator();

Feature area

Diagnostics

Affected APIs

DistributedContextPropagator.Current 
DistributedContextPropagator CreateDefaultPropagator()
@tarekgh tarekgh added the breaking-change Indicates a .NET Core breaking change label Apr 12, 2025
@dotnet-policy-service dotnet-policy-service bot added the ⌚ Not Triaged Not triaged label Apr 12, 2025
@gewarren gewarren changed the title [Breaking change]: Sitch the default trace context propagator from Legacy to W3C [Breaking change]: Switch the default trace context propagator from Legacy to W3C Apr 12, 2025
@gewarren gewarren assigned CamSoper and unassigned gewarren Apr 12, 2025
@CamSoper
Copy link
Contributor

@tarekgh Is this going out with the Preview 4 release?

@tarekgh
Copy link
Member Author

tarekgh commented Apr 13, 2025

@CamSoper Yes, the plan is to get this in preview 4. You can watch the PR dotnet/runtime#114583 to know when this will get merged.

@CamSoper CamSoper added 🏁 Release: .NET 10 Work items for the .NET 10 release and removed ⌚ Not Triaged Not triaged labels Apr 14, 2025
@CamSoper CamSoper moved this from 🔖 Ready to 🏗 In progress in dotnet/docs April 2025 sprint project Apr 14, 2025
@dotnetrepoman dotnetrepoman bot added the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 14, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 14, 2025
@CamSoper CamSoper pinned this issue Apr 14, 2025
@CamSoper
Copy link
Contributor

@gewarren We don't seem to have an existing "diagnostics" area in the breaking changes. Do we create a new one or does this fit under one of the existing ones?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 10 Work items for the .NET 10 release
Projects
Status: 🏗 In progress
Development

No branches or pull requests

3 participants