telemetry

package
v0.18.58 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package telemetry provides OpenTelemetry tracing for Wadjet.

Wadjet already generates W3C-compatible TraceID/SpanID and propagates them through NATS tasks. This package bridges those IDs into the OTel SDK so they are exported to Jaeger, Tempo, or any OTLP-compatible backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SpanIDFromContext

func SpanIDFromContext(ctx context.Context) string

SpanIDFromContext extracts the current span's ID as a hex string. Useful for propagating through Wadjet's task system.

func TraceIDFromContext

func TraceIDFromContext(ctx context.Context) string

TraceIDFromContext extracts the current trace ID as a hex string.

func TraceIDToBytes

func TraceIDToBytes(hexID string) [16]byte

TraceIDToBytes converts a 32-char hex trace ID to [16]byte.

Types

type Config

type Config struct {
	Endpoint    string  // OTLP gRPC endpoint (e.g., "localhost:4317")
	Insecure    bool    // use plaintext gRPC (no TLS)
	ServiceName string  // service name (default: "wadjet")
	SampleRate  float64 // sampling rate 0.0-1.0 (default: 1.0 = always)
}

Config configures the OTLP trace exporter.

type Provider

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

Provider wraps an OTel TracerProvider for clean shutdown.

func Init

func Init(ctx context.Context, cfg Config, logger *slog.Logger) (*Provider, error)

Init initializes the OTLP trace exporter and registers a global TracerProvider. Returns a Provider that must be shut down on exit.

func (*Provider) Shutdown

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

Shutdown flushes pending spans and shuts down the exporter.

func (*Provider) StartRemoteSpan

func (p *Provider) StartRemoteSpan(ctx context.Context, name, traceIDHex, parentSpanIDHex string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartRemoteSpan begins a span linked to a remote parent identified by the Wadjet TraceID/SpanID strings (from distributed.TraceContext). This bridges Wadjet's custom propagation to OTel spans.

func (*Provider) StartSpan

func (p *Provider) StartSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)

StartSpan begins a new span as a child of the current context.

func (*Provider) Tracer

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

Tracer returns the Wadjet tracer for creating spans.

Jump to

Keyboard shortcuts

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