Documentation
¶
Overview ¶
Package observability provides Draugr's logging and telemetry foundations: structured logging via log/slog and distributed tracing via OpenTelemetry.
Security note: logs and spans must never carry secrets (tokens, credentials, full request/response bodies). Scanners and plugins are responsible for redacting sensitive values before they reach a logger or span attribute.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
NewLogger builds a slog.Logger writing to w according to opts.
The default format is a human-readable console: Draugr is developer-first, so a person running it in a terminal should see legible, colorized logs, not JSON. Color is emitted only when w is an interactive terminal (and NO_COLOR is unset), so piped or redirected output stays plain text. Structured JSON is available on demand (Format "json") for CI and observability pipelines that consume machine-readable logs.
func SetDefault ¶
SetDefault installs l as the process-wide default slog logger.
Types ¶
type LogOptions ¶
type LogOptions struct {
Level string // debug | info | warn | error
Format string // console | json | text
}
LogOptions configures the structured logger.
type ShutdownFunc ¶
ShutdownFunc flushes and releases telemetry resources. It is always safe to call.
func InitMetrics ¶
func InitMetrics(ctx context.Context, service, version string) (ShutdownFunc, error)
InitMetrics configures an OpenTelemetry meter provider for the process.
Like tracing, it is opt-in and standards-based: with no OTLP endpoint configured via the standard OTEL_EXPORTER_OTLP_ENDPOINT / OTEL_EXPORTER_OTLP_METRICS_ENDPOINT environment variables, metrics are a no-op. When an endpoint is set, metrics are exported over OTLP/gRPC. Returns a shutdown func that flushes and releases resources.
func InitTracing ¶
func InitTracing(ctx context.Context, service, version string) (ShutdownFunc, error)
InitTracing configures an OpenTelemetry tracer provider for the process.
It is opt-in and standards-based: if no OTLP endpoint is configured via the standard OTEL_EXPORTER_OTLP_ENDPOINT / OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variables, tracing is a no-op with zero overhead. When an endpoint is set, spans are exported over OTLP/gRPC. All exporter tuning (endpoint, headers, TLS, sampling) uses the standard OTEL_* environment variables.