You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Request to support W3C TraceContext Level 2: Setting "random traceid flag" in tracecontext #91282
As part of the W3C Distributed Tracing working group, on 18th April 2023 we published the Level 2 (aka version 2) of the W3C Trace Context spec in "Candidate Recommendation" (CR) status: [https://www.w3.org/TR/trace-context-2/]
The main change is that this includes a new flag called the "random trace id" flag in the traceflags in the traceparent header, which when set, conveys that at least the right-most 7 bytes of the trace ID have been generated in a random (or pseudo-random) manner. This can be helpful for samplers / sharding logic etc. as with this they can get stronger guarantees that traceID has been generated in a random/pseudo-random manner.
Wanted to update you on this spec for your evaluation and to consider adoption as part of .NET 9. Assuming the traceID is already being generated in a pseudo-random manner, this would involve setting the corresponding trace flag to reflect it.
@jeffhandley I was just reviewing this with regard to implementing samplers based on this OTel spec. I see this has been bumped from .NET 10. It looks like the default behaviour is randomised, although consumers can pass their own IDs which may not be random. If I (or someone else) were to look at what's required to track the use of the random generator and then apply the flag, would that PR potentially make it in? I presume API changes may be required for cases where an ID is provided by the consumer to set the random flag, but for a first pass, we could set it when we know the runtime generated it?
@stevejgordon the specs still not stable to support that in the runtime. This is unlikely to be done before we ship .NET 10. We can target this for .NET 11 when the spec is finalized.
I wonder if there is a chicken-and-egg problem. The draft includes this text:
As an exit criteria, the Working Group intends to demonstrate at least 2 implementations adopting this specification and making use of it, using a test suite.
Does that refer only to officially released and supported implementations, or would a fork of .NET Runtime also count if it implemented the new bit and had tests for it?
I find it hard to understand why the W3C process needs to differ from other standardization approaches. My concern is: what happens if a product adopts a specification, and then, before it becomes stable, the spec changes? In .NET, I don’t think we should risk rushing to support unstable specs, as that could lead to deprecations or breaking changes down the line.
Activity
stevejgordon commentedon Aug 19, 2025
@jeffhandley I was just reviewing this with regard to implementing samplers based on this OTel spec. I see this has been bumped from .NET 10. It looks like the default behaviour is randomised, although consumers can pass their own IDs which may not be random. If I (or someone else) were to look at what's required to track the use of the random generator and then apply the flag, would that PR potentially make it in? I presume API changes may be required for cases where an ID is provided by the consumer to set the random flag, but for a first pass, we could set it when we know the runtime generated it?
tarekgh commentedon Aug 19, 2025
@stevejgordon the specs still not stable to support that in the runtime. This is unlikely to be done before we ship .NET 10. We can target this for .NET 11 when the spec is finalized.
KalleOlaviNiemitalo commentedon Aug 20, 2025
I wonder if there is a chicken-and-egg problem. The draft includes this text:
Does that refer only to officially released and supported implementations, or would a fork of .NET Runtime also count if it implemented the new bit and had tests for it?
tarekgh commentedon Aug 20, 2025
I find it hard to understand why the W3C process needs to differ from other standardization approaches. My concern is: what happens if a product adopts a specification, and then, before it becomes stable, the spec changes? In .NET, I don’t think we should risk rushing to support unstable specs, as that could lead to deprecations or breaking changes down the line.
tarekgh commentedon Feb 17, 2026
Closing this for the favor of #124509 which contains more information.