Skip to content

Request to support W3C TraceContext Level 2: Setting "random traceid flag" in tracecontext #91282

Closed as duplicate

Description

@kalyanaj

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.

CC: @tarekgh

Activity

  1. added this to the 9.0.0 milestone on Aug 29, 2023
  2. ghost added
    untriaged
    on Aug 29, 2023
  3. removed
    untriaged
    on Aug 29, 2023
  4. modified the milestones: 9.0.0, Future on Jan 10, 2024
  5. modified the milestones: Future, 10.0.0 on Oct 7, 2024
  6. self-assigned this
    on Oct 7, 2024
  7. modified the milestones: 10.0.0, Future on Jul 26, 2025
  8. stevejgordon commented on Aug 19, 2025

    @stevejgordon
    Contributor

    @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?

  9. tarekgh commented on Aug 19, 2025

    @tarekgh
    Member

    @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.

  10. KalleOlaviNiemitalo commented on Aug 20, 2025

    @KalleOlaviNiemitalo

    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?

  11. tarekgh commented on Aug 20, 2025

    @tarekgh
    Member

    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.

  12. tarekgh commented on Feb 17, 2026

    @tarekgh
    Member

    Closing this for the favor of #124509 which contains more information.

  13. locked and limited conversation to collaborators on Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions