Skip to content

Commit 8026c54

Browse files
committed
unused bit to not fail traceparent parsing
W3C standard says the interpretation of trace flag should only look for the supported bit, in this case the sampled bit. Therefore the presence of unused bit should not fail the parsing.
1 parent 97a78c1 commit 8026c54

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
3333

3434
### Changed
3535

36+
- Unused bit in trace flag will no longer fail the traceparent header parsing. Instead the unused bits are discarded while the supported bit is kept. (#7398)
3637
- Rename the `OTEL_GO_X_SELF_OBSERVABILITY` environment variable to `OTEL_GO_X_OBSERVABILITY` in `go.opentelemetry.io/otel/sdk/trace`, `go.opentelemetry.io/otel/sdk/log`, and `go.opentelemetry.io/otel/exporters/stdout/stdouttrace`. (#7302)
3738
- Improve performance of histogram `Record` in `go.opentelemetry.io/otel/sdk/metric` when min and max are disabled using `NoMinMax`. (#7306)
3839
- `WithInstrumentationAttributes` in `go.opentelemetry.io/otel/trace` synchronously de-duplicates the passed attributes instead of delegating it to the returned `TracerOption`. (#7266)

propagation/trace_context.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ func (TraceContext) extract(carrier TextMapCarrier) trace.SpanContext {
104104
if !extractPart(opts[:], &h, 2) {
105105
return trace.SpanContext{}
106106
}
107-
if version == 0 && (h != "" || opts[0] > 2) {
108-
// version 0 not allow extra
109-
// version 0 not allow other flag
110-
return trace.SpanContext{}
111-
}
112107

113108
// Clear all flags other than the trace-context supported sampling bit.
114109
scc.TraceFlags = trace.TraceFlags(opts[0]) & trace.FlagsSampled

propagation/trace_context_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ func TestExtractValidTraceContext(t *testing.T) {
8181
Remote: true,
8282
}),
8383
},
84+
{
85+
name: "current version unused bit set",
86+
header: http.Header{
87+
traceparent: []string{"00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09"},
88+
},
89+
sc: trace.NewSpanContext(trace.SpanContextConfig{
90+
TraceID: traceID,
91+
SpanID: spanID,
92+
TraceFlags: trace.FlagsSampled,
93+
Remote: true,
94+
}),
95+
},
8496
{
8597
name: "future version not sampled",
8698
header: http.Header{
@@ -228,10 +240,6 @@ func TestExtractInvalidTraceContextFromHTTPReq(t *testing.T) {
228240
name: "zero trace ID and span ID",
229241
header: "00-00000000000000000000000000000000-0000000000000000-01",
230242
},
231-
{
232-
name: "trace-flag unused bits set",
233-
header: "00-ab000000000000000000000000000000-cd00000000000000-09",
234-
},
235243
{
236244
name: "missing options",
237245
header: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7",

0 commit comments

Comments
 (0)