Documentation
¶
Overview ¶
Package metrics builds an OpenTelemetry MeterProvider that pushes metrics on a periodic interval to the exporter in a resolved otelcore.Settings: a collector, a slog logger or a writer. It produces no metrics itself: install the provider globally and instrumentation such as go/transit's OTel middleware reads it.
Index ¶
Constants ¶
const DefaultInterval = 60 * time.Second
DefaultInterval is the metric export interval applied when none is configured.
Variables ¶
This section is empty.
Functions ¶
func NewProvider ¶
func NewProvider( ctx context.Context, res *resource.Resource, s otelcore.Settings, opts ...Option, ) (*sdkmetric.MeterProvider, error)
NewProvider builds a MeterProvider that pushes metrics to s.Exporter on a periodic interval. A nil s.Exporter means otelcore.Collector{}, which reads the standard OTEL_EXPORTER_OTLP_* environment variables.
The caller owns the returned provider's Shutdown — typically by registering it on the controls.Controller so the final metric batch flushes on graceful stop.
Types ¶
type Option ¶
type Option func(*config)
Option configures the meter provider.
func WithInterval ¶
WithInterval sets the PeriodicReader export interval. Defaults to DefaultInterval.