telemetry

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

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

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

func Setup(ctx context.Context, debug bool) (shutdown func(context.Context) error, err error)

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.

Jump to

Keyboard shortcuts

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