headers

package module
v0.0.0-...-d9be2cd Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceFormatOTEL    = "otel"
	TraceFormatDatadog = "datadog"
	TraceFormatBoth    = "both"
)

Trace format constants

View Source
const (
	TraceparentHeader = "traceparent"
	TracestateHeader  = "tracestate"
)

W3C Trace Context headers

View Source
const (
	DatadogTraceIDHeader          = "x-datadog-trace-id"
	DatadogParentIDHeader         = "x-datadog-parent-id"
	DatadogSamplingPriorityHeader = "x-datadog-sampling-priority"
	DatadogOriginHeader           = "x-datadog-origin"
)

Datadog trace headers

Variables

This section is empty.

Functions

func CopyAll

func CopyAll(outReq *http.Request, req *http.Request)

func CopyAllSecure

func CopyAllSecure(outReq *http.Request, req *http.Request)

func EnsureRootSpan

func EnsureRootSpan(ctx context.Context, operationName string) (context.Context, trace.Span)

EnsureRootSpan creates a root span if none exists in the context Returns the context with span and the span itself

func ExtractTraceContext

func ExtractTraceContext(req *http.Request) context.Context

ExtractTraceContext extracts trace context from incoming request headers Supports both W3C traceparent and Datadog headers

func InjectTraceHeaders

func InjectTraceHeaders(ctx context.Context, req *http.Request, format string)

InjectTraceHeaders injects trace headers into outgoing request based on format

func ParseTraceparent

func ParseTraceparent(traceparent string) (traceID, spanID string, sampled bool, err error)

ParseTraceparent parses a W3C traceparent header value

func SetProxyHeaders

func SetProxyHeaders(outReq *http.Request, req *http.Request)

Types

type TraceInfo

type TraceInfo struct {
	TraceID       string // 128-bit hex (OTEL format)
	SpanID        string // 64-bit hex (OTEL format)
	DDTraceID     string // 64-bit decimal (Datadog format - lower 64 bits of trace ID)
	DDSpanID      string // 64-bit decimal (Datadog format)
	Sampled       bool
	HasValidTrace bool
}

TraceInfo contains extracted trace information

func GetTraceInfo

func GetTraceInfo(ctx context.Context) TraceInfo

GetTraceInfo extracts trace information from context in both formats

Jump to

Keyboard shortcuts

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