Skip to content

Conversation

@nikhilmantri0902
Copy link
Contributor

Problem

  • The Go SDK masks trace flags to the sampled bit and rejects version 00 flags > 0x02.
  • This drops the W3C Trace Context Level 2 random Trace ID flag (0x02) and any forward-compatible bits.

Approach

  • Treat trace flags as an 8-bit bitmask across extract, storage, and inject.
  • Accept any flags for traceparent version 00 and preserve them unchanged.
  • Interpret only known bits for behavior (sampling uses 0x01); do not change sampling logic.

Implementation details

  • propagation/trace_context.go
    • Inject: emit sc.TraceFlags() without masking.
    • Extract: remove opts[0] > 2 rejection; store full flags byte in SpanContextConfig.TraceFlags.
  • propagation/trace_context_test.go
    • Add extract cases for 0x02 and 0x03; ensure 0x09 is preserved.
    • Remove "unused bits set" from invalid cases.
    • Inject cases preserve 0xff, 0x02, and 0x03.
    • Future-version flag tests now expect full byte, not masked.

Closes #7635

@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.7%. Comparing base (63b24b0) to head (0778d30).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #7834     +/-   ##
=======================================
- Coverage   81.7%   81.7%   -0.1%     
=======================================
  Files        304     304             
  Lines      23252   23252             
=======================================
- Hits       19009   19007      -2     
- Misses      3860    3862      +2     
  Partials     383     383             
Files with missing lines Coverage Δ
propagation/trace_context.go 96.9% <100.0%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nikhilmantri0902
Copy link
Contributor Author

Hi @dmathieu can you review this.

carrier.Set(tracestateHeader, ts)
}

// Clear all flags other than the trace-context supported sampling bit.
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we were doing this intentionally before. I'm hesitant to remove this behavior without understanding why it was added in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support the new W3C random flag

2 participants