tracing

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package tracing provides OpenTelemetry initialization and W3C trace context propagation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndSpan

func EndSpan(span trace.Span, err error, attrs ...attribute.KeyValue)

EndSpan finishes a span, recording error status if applicable.

func InjectGRPCMetadata

func InjectGRPCMetadata(ctx context.Context, md metadata.MD)

InjectGRPCMetadata injects W3C trace context into gRPC metadata.

func InjectHTTPHeaders

func InjectHTTPHeaders(ctx context.Context, headers http.Header)

InjectHTTPHeaders injects W3C trace context into HTTP headers.

func StartRequestSpan

func StartRequestSpan(ctx context.Context, tracer trace.Tracer, protocol, endpoint string) (context.Context, trace.Span)

StartRequestSpan starts a new span for a request operation.

Types

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider wraps the OTel TracerProvider and provides convenience methods.

func Init

func Init(ctx context.Context, cfg config.TracingConfig) (*Provider, error)

Init creates an OTel TracerProvider from config. Returns a no-op provider if tracing is disabled.

func (*Provider) ShouldPropagate

func (p *Provider) ShouldPropagate() bool

ShouldPropagate returns whether W3C trace headers should be injected.

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown flushes pending spans and shuts down the provider.

func (*Provider) Tracer

func (p *Provider) Tracer() trace.Tracer

Tracer returns the configured tracer. Returns a no-op tracer if tracing is disabled.

Jump to

Keyboard shortcuts

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