Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*config)
Option configures Provider construction.
func WithMetricsAddr ¶
WithMetricsAddr sets the TCP address for the Prometheus /metrics HTTP server (e.g. ":9090"). When not supplied, no HTTP server is started.
func WithOTLPEndpoint ¶
WithOTLPEndpoint sets the OTLP gRPC endpoint URL (e.g. "http://otel-collector:4317"). When not supplied, no OTLP exporter is created.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider manages metrics exporters: a Prometheus pull endpoint and/or an OTLP push exporter. Both are optional and independently controlled by the options passed to New.
func New ¶
New creates a Provider. If neither WithMetricsAddr nor WithOTLPEndpoint is supplied, a no-op MeterProvider is returned.
func NewFromEnv ¶
NewFromEnv creates a Provider using standard environment variables. METRICS_ADDR enables the Prometheus /metrics pull endpoint. OTEL_EXPORTER_OTLP_ENDPOINT enables OTLP gRPC push export. If neither variable is set, a no-op Provider is returned.
The returned shutdown func must be deferred by the caller. It shuts down all exporters with a 10-second deadline and writes any error to stderr.
func (*Provider) MeterProvider ¶
func (p *Provider) MeterProvider() otelmetric.MeterProvider
MeterProvider returns the underlying OTel MeterProvider.