metrics

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package metrics builds an OpenTelemetry MeterProvider that pushes metrics to an OTLP/HTTP collector on a periodic interval, configured from a resolved otelcore.Settings. It is one of the GTB observability signals; the standard server metrics (http.server.*, rpc.server.*) are produced by the otelhttp and otelgrpc instrumentation in pkg/http and pkg/grpc, which read whichever MeterProvider is installed globally.

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 the OTLP/HTTP collector described by s on a periodic interval. When s.Endpoint is empty the exporter falls back to 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