Documentation ¶
Overview ¶
This package implements the B3 propagator specification as defined at https://github.com/openzipkin/b3-propagation
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type B3 ¶
type B3 struct { // InjectEncoding are the B3 encodings used when injecting trace // information. If no encoding is specified (i.e. `B3Unspecified`) // `B3MultipleHeader` will be used as the default. InjectEncoding Encoding }
B3 propagator serializes SpanContext to/from B3 Headers. This propagator supports both versions of B3 headers,
- Single Header: b3: {TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
- Multiple Headers: x-b3-traceid: {TraceId} x-b3-parentspanid: {ParentSpanId} x-b3-spanid: {SpanId} x-b3-sampled: {SamplingState} x-b3-flags: {DebugFlag}
Example ¶
package main import ( "go.opentelemetry.io/contrib/propagators/b3" "go.opentelemetry.io/otel/api/global" "go.opentelemetry.io/otel/api/propagation" ) func main() { b3 := b3.B3{} // Register the B3 propagator globally. global.SetPropagators(propagation.New( propagation.WithExtractors(b3), propagation.WithInjectors(b3), )) }
Output:
Example (InjectEncoding) ¶
package main import ( "go.opentelemetry.io/contrib/propagators/b3" "go.opentelemetry.io/otel/api/global" "go.opentelemetry.io/otel/api/propagation" ) func main() { // Create a B3 propagator configured to inject context with both multiple // and single header B3 HTTP encoding. b3 := b3.B3{ InjectEncoding: b3.B3MultipleHeader | b3.B3SingleHeader, } global.SetPropagators(propagation.New( propagation.WithExtractors(b3), propagation.WithInjectors(b3), )) }
Output:
func (B3) Extract ¶
func (b3 B3) Extract(ctx context.Context, supplier propagation.HTTPSupplier) context.Context
Extract extracts a context from the supplier if it contains B3 headers.
func (B3) GetAllKeys ¶
func (B3) Inject ¶
func (b3 B3) Inject(ctx context.Context, supplier propagation.HTTPSupplier)
Inject injects a context into the supplier as B3 headers. The parent span ID is omitted because it is not tracked in the SpanContext.
type Encoding ¶
type Encoding uint8
Encoding is a bitmask representation of the B3 encoding type.
const ( // B3MultipleHeader is a B3 encoding that uses multiple headers to // transmit tracing information all prefixed with `x-b3-`. B3MultipleHeader Encoding = 1 << iota // B3SingleHeader is a B3 encoding that uses a single header named `b3` // to transmit tracing information. B3SingleHeader // B3Unspecified is an unspecified B3 encoding. B3Unspecified Encoding = 0 )
Click to show internal directories.
Click to hide internal directories.