package propagators
import "go.opentelemetry.io/otel/api/propagators"
Package propagators contains interface definition for BinaryFormat and TextFormat propagators and implementation of propagators for different format and suppliers.
Index ¶
- Constants
- type B3
- func (b3 B3) Extract(ctx context.Context, supplier Supplier) (core.SpanContext, dctx.Map)
- func (b3 B3) GetAllKeys() []string
- func (b3 B3) Inject(ctx context.Context, supplier Supplier)
- type BinaryFormat
- type NoopTextFormat
- func (np NoopTextFormat) Extract(ctx context.Context, supplier Supplier) (core.SpanContext, dctx.Map)
- func (np NoopTextFormat) GetAllKeys() []string
- func (np NoopTextFormat) Inject(ctx context.Context, supplier Supplier)
- type Supplier
- type TextFormat
- type TraceContext
Constants ¶
const ( B3SingleHeader = "X-B3" B3DebugFlagHeader = "X-B3-Flags" B3TraceIDHeader = "X-B3-TraceId" B3SpanIDHeader = "X-B3-SpanId" B3SampledHeader = "X-B3-Sampled" B3ParentSpanIDHeader = "X-B3-ParentSpanId" )
const ( TraceparentHeader = "Traceparent" CorrelationContextHeader = "Correlation-Context" )
Types ¶
type B3 ¶
type B3 struct { SingleHeader bool }
B3 propagator serializes core.SpanContext to/from B3 Headers. This propagator supports both version of B3 headers,
- Single Header : X-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}
If SingleHeader is set to true then X-B3 header is used to inject and extract. Otherwise, separate headers are used to inject and extract.
func (B3) Extract ¶
Extract retrieves B3 Headers from the supplier
func (B3) GetAllKeys ¶
func (B3) Inject ¶
type BinaryFormat ¶
type BinaryFormat interface { // ToBytes serializes span context into a byte array and returns the array. ToBytes(sc core.SpanContext) []byte // FromBytes de-serializes byte array into span context and returns the span context. FromBytes([]byte) core.SpanContext }
BinaryFormat is an interface that specifies methods to convert SpanContext to/from byte array.
func Binary ¶
func Binary() BinaryFormat
Binary creates a new propagator. The propagator implements ToBytes and FromBytes method to transform SpanContext to/from byte array.
type NoopTextFormat ¶
type NoopTextFormat struct{}
NoopTextFormat implements TextFormat that does nothing.
func (NoopTextFormat) Extract ¶
func (np NoopTextFormat) Extract(ctx context.Context, supplier Supplier) (core.SpanContext, dctx.Map)
Extract does nothing and returns an empty SpanContext
func (NoopTextFormat) GetAllKeys ¶
func (np NoopTextFormat) GetAllKeys() []string
GetAllKeys returns empty list of strings.
func (NoopTextFormat) Inject ¶
func (np NoopTextFormat) Inject(ctx context.Context, supplier Supplier)
Inject does nothing.
type Supplier ¶
Supplier is an interface that specifies methods to retrieve and store value for a key to an associated carrier. Get method retrieves the value for a given key. Set method stores the value for a given key.
type TextFormat ¶
type TextFormat interface { // Inject method retrieves current SpanContext from the ctx, encodes it into propagator // specific format and then injects the encoded SpanContext using supplier into a carrier // associated with the supplier. It also takes a correlationCtx whose values will be // injected into a carrier using the supplier. Inject(ctx context.Context, supplier Supplier) // Extract method retrieves encoded SpanContext using supplier from the associated carrier. // It decodes the SpanContext and returns it and a dctx of correlated context. // If no SpanContext was retrieved OR if the retrieved SpanContext is invalid then // an empty SpanContext is returned. Extract(ctx context.Context, supplier Supplier) (core.SpanContext, dctx.Map) // GetAllKeys returns all the keys that this propagator injects/extracts into/from a // carrier. The use cases for this are // * allow pre-allocation of fields, especially in systems like gRPC Metadata // * allow a single-pass over an iterator (ex OpenTracing has no getter in TextMap) GetAllKeys() []string }
TextFormat is an interface that specifies methods to inject and extract SpanContext and distributed context into/from a carrier using Supplier interface. For example, HTTP Trace Context propagator would encode SpanContext into W3C Trace Context Header and set the header into HttpRequest.
type TraceContext ¶
type TraceContext struct{}
TraceContext propagates SpanContext in W3C TraceContext format.
func (TraceContext) Extract ¶
func (hp TraceContext) Extract( ctx context.Context, supplier Supplier, ) (core.SpanContext, dctx.Map)
func (TraceContext) GetAllKeys ¶
func (hp TraceContext) GetAllKeys() []string
func (TraceContext) Inject ¶
func (hp TraceContext) Inject(ctx context.Context, supplier Supplier)
Source Files ¶
b3_propagator.go binary_propagator.go doc.go text_noop_propagator.go text_propagator.go trace_context_propagator.go
- Version
- v0.2.1
- Published
- Jan 8, 2020
- Platform
- darwin/amd64
- Imports
- 10 packages
- Last checked
- 1 hour ago –
Tools for package owners.