metrics

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 5 Imported by: 1

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

View Source
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

func WithInterval(d time.Duration) Option

WithInterval sets the PeriodicReader export interval. Defaults to DefaultInterval.

Jump to

Keyboard shortcuts

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