xray

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0, BSD-3-Clause Imports: 13 Imported by: 86

README

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.

Documentation

Overview

Package xray provides an OpenTelemetry propagator for the AWS XRAY propagation format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IDGenerator

type IDGenerator struct {
	sync.Mutex
	// 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

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(context.Context, 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

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

func (Propagator) Fields

func (Propagator) Fields() []string

Fields returns list of fields used by HTTPTextFormat.

func (Propagator) Inject

func (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