Version: v1.17.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 13 Imported by: 40


AWS X-Ray Propagator/IDGenerator

This package contains an AWS X-Ray compatible TextMapPropagator and IDGenerator.

traceIdRatioSampler and x-ray IDGenerator compatibility

It is a general suggestion to not use the traceIDRatioSampler while also using the X-Ray IDGenerator. The non-random nature of building an X-Ray traceId may lead to unexpected sampling results.




This section is empty.


This section is empty.


This section is empty.


type IDGenerator

type IDGenerator struct {
	// contains filtered or unexported fields

IDGenerator is used for generating a new traceID and spanID.

func NewIDGenerator

func NewIDGenerator() *IDGenerator

NewIDGenerator returns an IDGenerator reference used for sending traces to AWS X-Ray.

func (*IDGenerator) NewIDs

func (gen *IDGenerator) NewIDs(ctx context.Context) (trace.TraceID, trace.SpanID)

NewIDs returns a non-zero trace ID and a non-zero span ID. trace ID returned is based on AWS X-Ray TraceID format.

span ID is from a randomly-chosen sequence.

func (*IDGenerator) NewSpanID

func (gen *IDGenerator) NewSpanID(ctx context.Context, traceID trace.TraceID) trace.SpanID

NewSpanID returns a non-zero span ID from a randomly-chosen sequence.

type Propagator

type Propagator struct{}

Propagator serializes Span Context to/from AWS X-Ray headers.

Example AWS X-Ray format:

X-Amzn-Trace-Id: Root={traceId};Parent={parentId};Sampled={samplingFlag}.

func (Propagator) Extract

func (xray Propagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context

Extract gets a context from the carrier if it contains AWS X-Ray headers.

func (Propagator) Fields

func (xray Propagator) Fields() []string

Fields returns list of fields used by HTTPTextFormat.

func (Propagator) Inject

func (xray Propagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)

Inject injects a context to the carrier following AWS X-Ray format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL