1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00
Files
opentelemetry-go/propagation
Nikhil Mantri 8c91c83fb6 Feat: Have SpanContext support the new W3C random flag. (#7834)
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

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2026-03-04 14:28:59 +01:00
..
2024-03-26 20:13:54 +01:00