observability

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

func NewLogger(w io.Writer, opts LogOptions) (*slog.Logger, error)

NewLogger builds a slog.Logger writing to w according to opts. JSON is the default format because structured, machine-readable logs are the baseline for observability pipelines.

func SetDefault

func SetDefault(l *slog.Logger)

SetDefault installs l as the process-wide default slog logger.

Types

type LogOptions

type LogOptions struct {
	Level  string // debug | info | warn | error
	Format string // json | text
}

LogOptions configures the structured logger.

type ShutdownFunc

type ShutdownFunc func(context.Context) error

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.

Jump to

Keyboard shortcuts

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