tracecontext

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Datadog Trace Context propagator for OpenTelemetry

OpenTelemetry propagators are used to extract and inject context data from and into messages exchanged by applications. The propagator supported by this package is the Datadog Trace Context.

Trace context propagation

Span Context Size DD header key Size Text Format
TraceId 128 bits <--> x-datadog-trace-id 64 bits number base 10
SpanId 64 bits <--> x-datadog-parent-id 64 bits number base 10
Sampling decision 1 bit <--> x-datadog-sampling-priority bool "0" or "1"

You can find a getting started guide on opentelemetry.io.

Getting Started

go get github.com/SylvainDumas/opentelemetry-datadog-go

If you installed more packages than you intended, you can use go mod tidy to remove any unused packages.

import (
    //...
	"github.com/SylvainDumas/opentelemetry-datadog-go/propagators/tracecontext"
	"go.opentelemetry.io/otel"
)

func initTracerProvider() {
    // ...
	otel.SetTextMapPropagator(tracecontext.NewDefault())
}

Documentation

Documentation

Index

Constants

View Source
const (
	// DefaultTraceIDHeader specifies the key that will be used in HTTP headers
	// or text maps to store the trace ID.
	DefaultTraceIDHeader = "x-datadog-trace-id"

	// DefaultParentIDHeader specifies the key that will be used in HTTP headers
	// or text maps to store the parent ID.
	DefaultParentIDHeader = "x-datadog-parent-id"

	// DefaultPriorityHeader specifies the key that will be used in HTTP headers
	// or text maps to store the sampling priority value.
	DefaultPriorityHeader = "x-datadog-sampling-priority"
)

Variables

View Source
var ErrDuplicatedHeaderKey = errors.New("duplicated header key")

Functions

func New

func New(cfg ...configFn) (propagation.TextMapPropagator, error)

New returns a new propagator which uses TextMap to inject and extract values. It propagates trace and span IDs. To use the defaults, call with nothing.

func NewDefault

func NewDefault() propagation.TextMapPropagator

NewDefault returns a new propagator with default configuration which uses TextMap to inject and extract values. It propagates trace and span IDs.

func WithHeaderKey

func WithHeaderKey(value HeaderKey) configFn

func WithHeaderValueConverter

func WithHeaderValueConverter(headerConv HeaderValueConverterPort) configFn

Types

type HeaderKey

type HeaderKey struct {
	// TraceID specifies the key that will be used to store the trace ID.
	// It defaults to DefaultTraceIDHeader.
	TraceID string

	// ParentID specifies the key that will be used to store the parent ID.
	// It defaults to DefaultParentIDHeader.
	ParentID string

	// SampledPriority specifies the key that will be used to store the sampling priority.
	// It defaults to DefaultPriorityHeader.
	SampledPriority string
}

func (*HeaderKey) Validate

func (obj *HeaderKey) Validate() error

Validate checks if header keys are valid (no duplication, ...)

type HeaderValueConverterPort

type HeaderValueConverterPort interface {
	// contains filtered or unexported methods
}

func NewHeaderConvBinary

func NewHeaderConvBinary() HeaderValueConverterPort

func NewHeaderConvString

func NewHeaderConvString() HeaderValueConverterPort

Jump to

Keyboard shortcuts

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