Add ActivityTraceFlags.RandomTraceId flag#124851
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-activity |
There was a problem hiding this comment.
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.RandomTraceIdto the public API surface. - Add
Activity.RandomizedTraceIdconvenience property and set the flag when the default random trace-id generator is used. - Expand
ActivityTestscoverage 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)W3CIdFlagstype; the flag enum isActivityTraceFlags. Update the docs to referenceActivityTraceFlags.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; }
|
@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. |
Fixes #124509
Brings support for RandomTraceId flag known from W3C context propagation level 2.
More details in linked issue.