You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-08-10 22:31:50 +02:00
Make TraceFlags spec-compliant (#1770)
* Make TraceFlags spec-compliant * Remove `trace.FlagsDebug` and `trace.FlagsDeferred` * These are used only by the B3 propagator and will be handled there in the `context.Context` * Make `trace.TraceFlags` a defined type, aliasing `byte` * Move `IsSampled` method from `trace.SpanContext` to `trace.TraceFlags` * Add `Sampled(bool)` method to `trace.TraceFlags` * Implement `Stringer` and `json.Marshaler` for `trace.TraceFlags` Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com> * Rename `TraceFlags.Sampled()` to `TraceFlags.WithSampled()` for consistency * Restore `SpanContext.IsSampled()` method. Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
This commit is contained in:
committed by
GitHub
parent
ee687ca5c8
commit
c6b92d5b20
@@ -54,11 +54,14 @@ func (tc TraceContext) Inject(ctx context.Context, carrier TextMapCarrier) {
|
||||
|
||||
carrier.Set(tracestateHeader, sc.TraceState().String())
|
||||
|
||||
h := fmt.Sprintf("%.2x-%s-%s-%.2x",
|
||||
// Clear all flags other than the trace-context supported sampling bit.
|
||||
flags := sc.TraceFlags() & trace.FlagsSampled
|
||||
|
||||
h := fmt.Sprintf("%.2x-%s-%s-%s",
|
||||
supportedVersion,
|
||||
sc.TraceID(),
|
||||
sc.SpanID(),
|
||||
sc.TraceFlags()&trace.FlagsSampled)
|
||||
flags)
|
||||
carrier.Set(traceparentHeader, h)
|
||||
}
|
||||
|
||||
@@ -134,7 +137,7 @@ func (tc TraceContext) extract(carrier TextMapCarrier) trace.SpanContext {
|
||||
return trace.SpanContext{}
|
||||
}
|
||||
// Clear all flags other than the trace-context supported sampling bit.
|
||||
scc.TraceFlags = opts[0] & trace.FlagsSampled
|
||||
scc.TraceFlags = trace.TraceFlags(opts[0]) & trace.FlagsSampled
|
||||
|
||||
scc.TraceState = parseTraceState(carrier.Get(tracestateHeader))
|
||||
scc.Remote = true
|
||||
|
Reference in New Issue
Block a user