Make DistributedContextPropagator opt-in (keep OTel propagation backwards compatible until v11)#7825
Merged
Merged
Conversation
ramonsmits
commented
Jun 17, 2026
irinascurtu
approved these changes
Jun 17, 2026
tmasternak
requested changes
Jun 18, 2026
The switch to System.Diagnostics.DistributedContextPropagator changes the OpenTelemetry baggage wire format (W3C OWS encoding + whitespace trimming), which is breaking on rolling upgrades. Keep the legacy percent-encoded propagator as the default and gate the new propagator behind the NServiceBus.Core.OpenTelemetry.UseDistributedContextPropagator AppContext switch (default in v11). All temporary code (switch plumbing + legacy propagator) lives in obsolete_v11.cs so v11 cleanup is a single file deletion plus removing the two delegation blocks in ContextPropagation.cs. Follows the existing AppContextSwitches.UseV2DeterministicGuid / PreObsolete pattern. - ContextPropagation: delegate to the legacy propagator unless the switch is on - obsolete_v11.cs: switch + byte-for-byte revert of the pre-10.3 propagator - Tests asserting the new W3C format enable the switch per-fixture - New ContextPropagationDefaultBehaviorTests locks in legacy default behavior - Acceptance baggage assertion reverted to the legacy default wire format Span naming (UseMessageDestinationInSpanNames) is already opt-in and unchanged.
…scaping and trimming values
…ator baggage values.
…extPropagation delegates
…emove outdated baggage handling tests
5ca5b34 to
f2b6066
Compare
tmasternak
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacks on #7798 (
otel). Keeps the newDistributedContextPropagator-based OpenTelemetry context propagation opt-in so 10.3 stays backwards compatible, with the new behavior becoming the default in v11.Why
otel(commit bba80f7) replaced the hand-written baggage propagator withSystem.Diagnostics.DistributedContextPropagator. The HTTP header names are unchanged (traceparent/tracestate/baggagewere already W3C), but the baggage value encoding changes:DistributedContextPropagator)key1=value1,key2=value2key1 = value1, key2 = value2(W3C OWS)Uri.EscapeDataStringwhole valueContextPropagationIncompatibilityTestsdocuments the breakage: new→legacy gains a leading space, and new round-trips strip value whitespace. That's breaking on rolling upgrades, so it can't ship default-on in a minor.What
NServiceBus.Core.OpenTelemetry.UseDistributedContextPropagator, mirroring the existingAppContextSwitches.UseV2DeterministicGuid/[PreObsolete]pattern (flip default in v11, remove the switch + legacy code in v11).obsolete_v11.cs— the switch plumbing plus a byte-for-byte revert of the pre-10.3 propagator. v11 cleanup = delete that one file + remove the twoif (!ObsoleteV11.UseDistributedContextPropagator)delegation blocks inContextPropagation.cs.ContextPropagation.cskeeps the newDistributedContextPropagatorimplementation as the permanent/future path.UseMessageDestinationInSpanNamesvia the publicTracing()API) is already opt-in/non-breaking — left untouched.Enabling the switch: