Documentation
¶
Overview ¶
Package telemetry wires up OpenTelemetry SDK providers and a structured slog logger for allbctl.
Three independent signal paths exist and can be active simultaneously:
Console path (--debug flag): traces → stdouttrace pretty-print on stderr; metrics → JSON slog records on stderr at shutdown; slog logger → JSON on stderr.
OTLP path (OTEL_EXPORTER_OTLP_ENDPOINT env var): traces, metrics, and logs are shipped via OTLP HTTP to the configured endpoint (e.g. a local Grafana LGTM stack). This is always active when the env var is set, regardless of the --debug flag.
When neither path is active, no-op providers are installed so instrumented code compiles and runs with zero overhead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Logger = slog.New(slog.NewTextHandler(io.Discard, nil))
Logger is the process-wide structured logger. It discards all records until Setup is called with debug=true or OTEL_EXPORTER_OTLP_ENDPOINT is set.
Functions ¶
func RecordCommandMetrics ¶
func RecordCommandMetrics(ctx context.Context, commandPath string, duration time.Duration, success bool)
RecordCommandMetrics records invocation count and duration for a command. It is called by the root PersistentPostRunE after each command completes.
func Setup ¶
Setup initialises the OpenTelemetry SDK. Call the returned shutdown function (exactly once) to flush and stop all providers.
- debug=true enables the console (stderr) signal path.
- OTEL_EXPORTER_OTLP_ENDPOINT being set enables the OTLP signal path.
If neither is active, no-op providers are installed.
Types ¶
This section is empty.