Skip to content

Add ActivityTraceFlags.RandomTraceId flag#124851

Draft
Kielek wants to merge 1 commit intodotnet:mainfrom
Kielek:activity-traceidrandom
Draft

Add ActivityTraceFlags.RandomTraceId flag#124851
Kielek wants to merge 1 commit intodotnet:mainfrom
Kielek:activity-traceidrandom

Conversation

@Kielek
Copy link

@Kielek Kielek commented Feb 25, 2026

Fixes #124509

Brings support for RandomTraceId flag known from W3C context propagation level 2.
More details in linked issue.

Copilot AI review requested due to automatic review settings February 25, 2026 10:48
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 25, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-diagnostics-activity
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for the W3C Trace Context Level 2 random trace-flags bit by introducing ActivityTraceFlags.RandomTraceId and ensuring Activities created with the default trace-id generator set/propagate this flag.

Changes:

  • Add ActivityTraceFlags.RandomTraceId to the public API surface.
  • Add Activity.RandomizedTraceId convenience property and set the flag when the default random trace-id generator is used.
  • Expand ActivityTests coverage for parsing/propagating the new flag and validating default generation behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs Introduces RandomizedTraceId, sets RandomTraceId when using the default generator, and adds the new enum flag.
src/libraries/System.Diagnostics.DiagnosticSource/ref/System.Diagnostics.DiagnosticSourceActivity.cs Updates reference assembly API surface for the new property and enum member.
src/libraries/System.Diagnostics.DiagnosticSource/tests/ActivityTests.cs Adds/extends unit tests for RandomTraceId parsing, propagation, and default generation behavior.
Comments suppressed due to low confidence (1)

src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs:950

  • The XML documentation for RandomizedTraceId/Recorded refers to W3CIdFlags.*, but there is no public (or internal) W3CIdFlags type; the flag enum is ActivityTraceFlags. Update the docs to reference ActivityTraceFlags.RandomTraceId / ActivityTraceFlags.Recorded (or describe the W3C trace-flags field generically) to avoid misleading API docs.
        /// <summary>
        /// True if the W3CIdFlags.RandomTraceId flag is set.
        /// </summary>
        public bool RandomizedTraceId { get => (ActivityTraceFlags & ActivityTraceFlags.RandomTraceId) != 0; }

        /// <summary>
        /// True if the W3CIdFlags.Recorded flag is set.
        /// </summary>
        public bool Recorded { get => (ActivityTraceFlags & ActivityTraceFlags.Recorded) != 0; }

@tarekgh
Copy link
Member

tarekgh commented Feb 25, 2026

@Kielek thanks for submitting it. We need to design review it before we proceed with the changes. I have converted this PR to be draft for now till we do that. If you like we can temporary close the PR and then reactive it back when ready.

@tarekgh tarekgh added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 25, 2026
@tarekgh tarekgh self-assigned this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Diagnostics.Activity community-contribution Indicates that the PR has been added by a community member NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: ActivityTraceFlags.RandomTraceId flag

3 participants