tracing

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package tracing wires the OpenTelemetry SDK and exposes a small HTTP-middleware helper. When tracing is disabled, all helpers are no-ops so callers don't need to branch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, cfg Config) (func(context.Context) error, error)

Init constructs the tracer provider per cfg and installs it as the global OTel provider. Returns a shutdown function the caller invokes on exit. When cfg.Enabled is false, returns a no-op shutdown.

func Middleware

func Middleware(next http.Handler) http.Handler

Middleware returns HTTP middleware that emits one span per request, linking it to the request_id when present.

func Tracer

func Tracer(name string) trace.Tracer

Tracer returns a named tracer from the global provider. Safe to call when tracing is disabled (returns a no-op tracer).

Types

type Config

type Config struct {
	Enabled     bool
	Endpoint    string  // OTLP HTTP endpoint, e.g. "http://otel-collector:4318"
	SampleRate  float64 // 0..1
	ServiceName string
}

Config controls the SDK setup.

Jump to

Keyboard shortcuts

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