Documentation
¶
Overview ¶
Package otel provides OpenTelemetry initialization for tracing, metrics, and logging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHistograms = errors.New("invalid histograms aggregation")
ErrInvalidHistograms is returned by Setup when Config.Histograms holds an unknown value.
Functions ¶
func Setup ¶
Setup initializes OpenTelemetry providers and registers shutdown handlers. Exporters are configured via OTEL_* environment variables.
Setup wraps the handler of slog.Default() in a slogutil.ContextHandler, unless it already is one, so records logged with a context carry its correlation fields. It returns ErrInvalidHistograms if cfg.Histograms is unknown.
Types ¶
type Config ¶
type Config struct {
// ServiceName is the name of the service. Required.
ServiceName string `koanf:"service_name"`
// ServiceVersion is the version of the service. Required.
ServiceVersion string `koanf:"service_version"`
// Histograms selects the aggregation of all histogram instruments.
// Valid values: "exponential", "explicit".
// Default: "exponential"
Histograms Histograms `koanf:"histograms"`
}
Config holds the configuration for OpenTelemetry setup.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with default values. ServiceName and ServiceVersion are required and must be set by the caller.
type Histograms ¶ added in v0.8.0
type Histograms string
Histograms is the aggregation used for histogram instruments.
const ( // HistogramsExponential aggregates histograms as base-2 exponential // histograms, which Prometheus-compatible backends ingest as native // histograms. HistogramsExponential Histograms = "exponential" // HistogramsExplicit aggregates histograms into the explicit bucket // boundaries advised by each instrument. HistogramsExplicit Histograms = "explicit" )