Documentation
¶
Overview ¶
Package observability wires structured logging, tracing, and metrics: an slog logger with trace correlation and secret redaction, and OpenTelemetry tracer and meter providers exported via OTLP and Prometheus.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
NewLogger builds the application logger: leveled output, trace correlation, and sensitive-value redaction applied to every record. format is "json" (default) or "text".
func ParseLevel ¶
ParseLevel maps a config string to an slog.Level, defaulting to info.
Types ¶
type RedactingHandler ¶
type RedactingHandler struct {
// contains filtered or unexported fields
}
RedactingHandler wraps a slog.Handler and replaces the values of attributes whose key looks sensitive, recursing into groups. It guards against logging credentials by accident, which is the most common log-hygiene failure.
func NewRedactingHandler ¶
func NewRedactingHandler(next slog.Handler) *RedactingHandler
type Telemetry ¶
type Telemetry struct {
Registry *prometheus.Registry
// contains filtered or unexported fields
}
Telemetry owns the metric registry and a single shutdown hook that flushes and stops every provider in reverse order of construction.
type TelemetryConfig ¶
type TelemetryConfig struct {
ServiceName string
ServiceVersion string
Environment string
OTLPEndpoint string
SampleRatio float64
}
TelemetryConfig configures tracing and metrics. When OTLPEndpoint is empty tracing is disabled but metrics (scraped from the returned registry) stay on.
type TraceHandler ¶
type TraceHandler struct {
// contains filtered or unexported fields
}
TraceHandler injects the active span's trace and span IDs into every record, so a log line links straight to its trace in Tempo. The IDs are read at emit time from the context, so they always reflect the current span.
func NewTraceHandler ¶
func NewTraceHandler(next slog.Handler) *TraceHandler