Documentation
¶
Overview ¶
Package tracing provides OpenTelemetry tracing initialization and helpers.
Index ¶
- func ExtractTraceContext(ctx context.Context, data map[string]interface{}) context.Context
- func ExtractTraceContextFromHeader(ctx context.Context, header http.Header) context.Context
- func InitTracer(ctx context.Context, serviceName string, cfg config.TracingConfig) (func(context.Context) error, error)
- func NewTraceHandler(inner slog.Handler) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTraceContext ¶
ExtractTraceContext extracts trace context from a data map and returns a new context with the extracted span context. If no trace context is present, the original context is returned.
func ExtractTraceContextFromHeader ¶
ExtractTraceContextFromHeader extracts trace context from HTTP-compatible headers and returns a new context. If no trace context is present, the original context is returned.
Header keys are normalized to canonical MIME format before extraction. Some transports (e.g., NATS JetStream) deliver headers with non-canonical casing (lowercase "traceparent" instead of "Traceparent"), which breaks http.Header.Get lookups. Normalizing ensures reliable extraction.
func InitTracer ¶
func InitTracer( ctx context.Context, serviceName string, cfg config.TracingConfig, ) (func(context.Context) error, error)
InitTracer initializes the OpenTelemetry tracer provider. It always sets the global W3C TraceContext propagator. When tracing is disabled, a noop provider is used. Returns a shutdown function that must be called on exit.
Types ¶
This section is empty.