Edit

Share via


Default trace context propagator updated to W3C standard

The default trace context propagator has been switched from the legacy propagator to the W3C propagator. The new propagator uses the baggage header instead of Correlation-Context, enforces W3C-compliant encoding, and supports only W3C-formatted trace parent IDs.

Version introduced

.NET 10 Preview 4

Previous behavior

The DistributedContextPropagator.CreateDefaultPropagator() method returned an instance of the legacy propagator. By default, DistributedContextPropagator.Current was set to this legacy instance.

New behavior

The DistributedContextPropagator.CreateDefaultPropagator() method now returns an instance of the W3C propagator. By default, DistributedContextPropagator.Current is set to this W3C instance.

Example of setting the default propagator to the legacy propagator:

DistributedContextPropagator.Current = DistributedContextPropagator.CreatePreW3CPropagator();

Type of breaking change

This is a behavioral change.

Reason for change

This change ensures full compliance with the W3C Trace Context and Baggage specifications. The W3C propagator enforces strict formatting for trace parent, trace state, and baggage keys and values, aligning with the W3C standards. The legacy propagator was more lenient and used the non-standard Correlation-Context header for baggage propagation.

For more details, see the following GitHub issues:

If you need to retain the legacy behavior, use the DistributedContextPropagator.CreatePreW3CPropagator() method to retrieve the legacy propagator instance. Set it as the current propagator as shown below:

DistributedContextPropagator.Current = DistributedContextPropagator.CreatePreW3CPropagator();

Affected APIs