Documentation
¶
Overview ¶
Package telemetry wires up OpenTelemetry tracing and logging for the app.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseHeaders ¶
ParseHeaders parses the OTLP headers env-var format ("key1=value1,key2=value2") into a header map suitable for Config.Headers.
func Setup ¶
Setup wires up OpenTelemetry tracing and logging and installs an slog.Logger as the process default. It always logs to stdout; when cfg.Endpoint is set it additionally exports traces and logs over OTLP/HTTP.
The returned shutdown func flushes and closes any exporters that were created; call it (typically deferred) before the process exits.
Types ¶
type Config ¶
type Config struct {
ServiceName string
ServiceVersion string
// Endpoint is the OTLP/HTTP collector endpoint, e.g. "http://localhost:4318"
// or "https://collector.example.com". If empty, OTLP export is disabled:
// tracer.Start calls throughout the app fall back to OpenTelemetry's
// built-in no-op tracer, and logging stays stdout-only.
Endpoint string
// Headers are sent with every OTLP export request, e.g. for collector
// authentication.
Headers map[string]string
}
Config controls where telemetry is exported to.
Click to show internal directories.
Click to hide internal directories.