Covers the traceparent and tracestate formats, the sampled flag, W3C Baggage and its risks, DistributedContextPropagator and the .NET 10 switch to the W3C propagator, interoperating with B3 and vendors, and trust boundaries at the public edge.
W3C Trace Context standardises how a trace crosses process boundaries. traceparent is version-traceid-parentid-flags, for example 00-4bf92f35...4736-00f067aa0ba902b7-01, where the last byte's low bit means sampled. tracestate carries up to 32 vendor-specific key=value entries that every hop must forward even if it doesn't understand them.
W3C Baggage (baggage header) carries application key/values, such as a tenant tier, to every downstream service, in clear text. Use it sparingly and never for personal data.
In .NET, HttpClient writes the headers through DistributedContextPropagator.Current, and since .NET 10 that is the W3C propagator by default (standard baggage instead of Correlation-Context). OpenTelemetry uses TraceContext + Baggage propagators, plus B3 if you talk to Zipkin-era systems.
The trade-off: trusting inbound context gives end-to-end traces with partners, but at the public edge it lets anyone set your sampling and baggage.
"W3C Trace Context is the standard that lets a trace survive a hop between services written by different teams or vendors. It defines two HTTP headers.
traceparenthas four dash-separated fields: a version, which is00today; the 32-hex-character trace id; the 16-hex-character id of the calling span, which becomes the parent; and a flags byte where bit 0 says whether the caller sampled the trace.tracestateis a list of up to 32 vendor entries, likecongo=t61rcWkgMzE, which carries vendor-specific data; the rule is that you forward it unchanged, and a vendor only edits its own entry, moving it to the front.Separate from that is W3C Baggage, a
baggageheader of application key/values that propagates to every downstream hop. It's useful for things like atenant.tier=goldthat a downstream service uses to tag its spans, but it's sent in clear text to every service and often to third-party APIs, so personal data never goes in it. In .NET,HttpClientinjects these headers throughDistributedContextPropagator.Current. In .NET 10 the default changed to the W3C propagator, so baggage now goes in the standardbaggageheader instead of the oldCorrelation-Context, and the legacy hierarchical ids are no longer propagated. If an old service still relies onCorrelation-Context,CreatePreW3CPropagator()restores the old behaviour while you migrate.The mistake I see is trusting inbound context from the internet. A client can send
traceparentwith the sampled flag set on every request and force you to record everything, or stuff baggage that you then forward to internal services. At the public edge I start a new trace, keep the external context only as a span link, and drop inbound baggage. Inside the trust boundary, propagate everything; at the edge, decide."
| Header | Format | Owner | Rules |
|---|---|---|---|
traceparent |
00-{trace-id 32 hex}-{parent-id 16 hex}-{flags 2 hex} |
Standard | All-zero ids are invalid; unknown versions parsed best-effort |
tracestate |
vendor1=value,vendor2=value (max 32 entries) |
Vendors | Forward unchanged; edit only your own entry and move it left |
baggage |
key=value;metadata,key2=value2 |
Application | Percent-encoded values; about 8,192 bytes total |
| Format | Headers | Seen in | .NET support |
|---|---|---|---|
| W3C Trace Context | traceparent, tracestate |
Everything modern | Default (TraceContextPropagator) |
| W3C Baggage | baggage |
OpenTelemetry | BaggagePropagator |
| B3 | X-B3-TraceId... or single b3 |
Zipkin-era services, some Envoy/Istio set-ups | B3Propagator in OpenTelemetry.Extensions.Propagators |
| Legacy .NET | Request-Id, Correlation-Context |
Old Application Insights SDK apps | CreatePreW3CPropagator() |
| Inbound from | Honour traceparent? | Honour sampled flag? | Honour baggage? |
|---|---|---|---|
| Your own services | Yes | Yes (ParentBased sampler) | Yes |
| Trusted partner with shared tracing | Yes, or link | Your choice | Only agreed keys |
| Public internet / browsers | Link only | No | No, strip it |
After an upgrade to .NET 10, a downstream service that read Correlation-Context for a tenant tier lost it, and 30% of its spans had no tenant.tier tag, breaking a per-tier latency dashboard. We updated the reader to OpenTelemetry's Baggage API (standard baggage header) within a day instead of reverting to the legacy propagator.
Checks that the candidate understands the wire format behind propagation and the security, cost and compatibility decisions around it.
Green flags
traceparent fields and the sampled flagtracestate forwarding rules and what baggage is forDistributedContextPropagatorRed flags
Before 2020 every vendor had its own headers: Zipkin's X-B3-*, Jaeger's uber-trace-id, Application Insights' Request-Id, AWS's X-Amzn-Trace-Id. A request crossing two vendors lost its trace. W3C Trace Context (a W3C Recommendation since February 2020) defines one wire format everyone can forward.
00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
| | | |
| trace-id: 16 bytes, random parent-id: 8 bytes trace-flags: 0x01 = sampled
version (00)
ParentBasedSampler follows it, so a trace is either fully recorded or fully dropped.An ordered list, left = most recently updated. Example: rojo=00f067aa0ba902b7,congo=t61rcWkgMzE. Vendors use it for things like their own sampling probability (OpenTelemetry uses the ot key for consistent probability sampling). Rules: at most 32 entries, keys lower-case, and a service that doesn't recognise an entry must forward it.
baggage: tenant.tier=gold,feature.checkout_v2=on
Baggage is not attached to spans automatically. A service must read it (Baggage.GetBaggage("tenant.tier")) and copy it onto spans or logs if wanted; OpenTelemetry has a baggage span processor in contrib for that. Each hop forwards it, so every value costs bytes on every downstream request, and anything in it can leak to any third party you call.
HttpClient -> SocketsHttpHandler -> DistributedContextPropagator.Current.Inject(activity, request)
ASP.NET Core hosting -> DistributedContextPropagator.Current.ExtractTraceIdAndState / ExtractBaggage
DistributedContextPropagator.CreateDefaultPropagator() returns the W3C propagator and Current defaults to it. Baggage uses baggage, only W3C-format ids are propagated, and keys and values are encoded per the spec. CreatePreW3CPropagator() gives back the legacy behaviour.SocketsHttpHandler.ActivityHeadersPropagator lets you override per handler; setting it to DistributedContextPropagator.CreateNoOutputPropagator() stops injection (useful for calls to third parties).Propagators.DefaultTextMapPropagator (composite TraceContext + Baggage) instead.traceparent for real end-to-end traces. Accept it from your own SPA origin if you want, but ignore the sampled flag and baggage.curl -H "traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01" and log Activity.Current?.TraceId and ParentSpanId.baggage: tier=gold and read it with Baggage.GetBaggage; then switch to CreatePreW3CPropagator() and see what changes.DelegatingHandler to print outgoing headers for an HttpClient call.CompositeTextMapPropagator with TraceContext, Baggage and B3, and call a service that only sends B3.ActivityHeadersPropagator to the no-output propagator for one named client and confirm the header is gone.Edge handling and propagation choices in an ASP.NET Core 10 service.
// Program.cs
using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Context.Propagation;
using OpenTelemetry.Extensions.Propagators; // B3Propagator
using OpenTelemetry.Trace;
var builder = WebApplication.CreateBuilder(args);
// During a migration from Zipkin-era services: extract and inject both W3C and B3.
Sdk.SetDefaultTextMapPropagator(new CompositeTextMapPropagator(
[
new TraceContextPropagator(),
new BaggagePropagator(),
new B3Propagator()
]));
builder.Services.AddOpenTelemetry().WithTracing(t => t
.SetSampler(new ParentBasedSampler(new TraceIdRatioBasedSampler(0.1)))
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddOtlpExporter());
// Calls to a third-party API: don't send our trace headers or baggage.
builder.Services.AddHttpClient("payments-provider")
.ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
{
ActivityHeadersPropagator = DistributedContextPropagator.CreateNoOutputPropagator()
});
var app = builder.Build();
// Public edge: never forward baggage that came from the internet.
app.Use(async (context, next) =>
{
context.Request.Headers.Remove("baggage");
Baggage.Current = default;
await next(context);
});
// Inside the trust boundary, set baggage for downstream services (no personal data).
app.MapGet("/orders/{id}", (Guid id, HttpContext http) =>
{
Baggage.SetBaggage("tenant.tier", http.User.FindFirst("tier")?.Value ?? "standard");
Activity.Current?.SetTag("tenant.tier", Baggage.GetBaggage("tenant.tier"));
return Results.Ok(new { id });
});
app.Run();
# See what the service makes of an incoming context
curl -s http://localhost:5000/orders/7c9e6679-7425-40de-944b-e07fc1f90ae7 \
-H "traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01" \
-H "tracestate: congo=t61rcWkgMzE"
Note: removing the baggage header in middleware runs after ASP.NET Core hosting has already extracted it into the request activity, which is why the example also clears Baggage.Current. For full control, strip the header at the gateway (Azure API Management or Application Gateway rewrite rules).
traceparent as the receiver's own span id. Why it is wrong: the receiver creates a new span; the header id is its parent. Instead: read it as "the caller's client span".tracestate entries you don't recognise. Why it is wrong: it breaks vendors further down the chain. Instead: forward unknown entries unchanged.Correlation-Context consumers. Why it is wrong: the default propagator now sends baggage, so old readers see nothing. Instead: move readers to the Baggage API, or temporarily set CreatePreW3CPropagator().The standard solves interoperability; the senior work is deciding where the trust boundary is. Inside it, forward everything and let the parent's sampling decision win so traces are complete. At the edge, treat inbound context as untrusted input, like any other header. Baggage is powerful but is effectively a global variable broadcast to every service; keep an allow-list of keys and review it like an API contract.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| W3C only | All peers on modern SDKs | None | Zipkin/B3 peers remain |
| Composite W3C + B3 | Migration from Zipkin or B3-configured mesh | Extra headers on every call | After migration |
Legacy propagator (CreatePreW3CPropagator) |
Short-term during .NET 10 upgrade | Non-standard headers | As a permanent setting |
| Suppress propagation | Calls to third parties | Lose their side of the trace | Partners who share your tracing |
Two mechanisms work together.
using (logger.BeginScope(new Dictionary<string, object> { ["OrderId"] = id })) adds properties to every log inside the block, flowing across await via AsyncLocal. ASP.NET Core already opens a scope per request with RequestId and RequestPath.Activity whose trace id comes from the incoming W3C traceparent header or is created new. With ActivityTrackingOptions (on by default in the Generic Host) every log carries TraceId and SpanId. HttpClient propagates traceparent automatically; message queues need it copied into message properties (the Azure Service Bus SDK does this).So the trace id is your correlation id; add business ids as properties. The trade-off: custom correlation headers are easy but don't interoperate with tracing tools.
Create a static ActivitySource, wrap the send in a Producer span and the handler in a Consumer span, and carry the context in the message. On send, call Propagators.DefaultTextMapPropagator.Inject to write traceparent (and tracestate/baggage) into ServiceBusMessage.ApplicationProperties. On receive, Extract it and pass the resulting ActivityContext as the parent to StartActivity, so the consumer's spans join the producer's trace.
The Azure SDK can do some of this itself: it writes Diagnostic-Id in traceparent format, and its own spans are experimental, needing the Azure.Experimental.EnableActivitySource switch and AddSource("Azure.Messaging.ServiceBus.*").
Tag spans with messaging semantic conventions. When one span handles a batch, or processing happens hours later, use span links instead of a parent. The trade-off: parent/child gives one tidy trace, but long-delayed work makes huge, misleading traces.
Treat logs as a data store that attackers and too many staff can read. Never log secrets (passwords, tokens, Authorization headers, connection strings, card numbers) and keep personal information out: log identifiers like CustomerId, not names, emails or request bodies.
Enforce it in code rather than by memory: Microsoft.Extensions.Compliance.Redaction lets you classify fields with attributes, map classifications to redactors (erase, or HMAC for a stable pseudonym) with AddRedaction, and apply them to logs with EnableRedaction. Use header allowlists in HTTP logging.
In Australia, APP 11 requires reasonable steps to protect personal information and APP 11.2 requires destroying or de-identifying it when no longer needed, so retention matters, and a leaked log store can be a notifiable data breach. The trade-off: less detail in logs versus a smaller breach surface.
How to tell it (STAR)
**S:** At [company], after upgrading part of our platform to .NET 10, gold customers started being throttled as standard. **T:** I had to restore correct behaviour fast and finish the migration properly. **A:** I captured the headers, found .NET 10 now sends standard W3C baggage instead of Correlation-Context, rolled back to the legacy propagator as a stopgap, then moved every reader to the Baggage API and added a cross-service contract test. **R:** Throttling complaints stopped [within the hour], and we removed the legacy propagator [two weeks] later with zero 'unknown' tier spans.
Last updated 23 Nov 2026.