metrics

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package metrics provides OpenTelemetry metrics integration for Bifrost.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMeterProvider

func GetMeterProvider() *sdkmetric.MeterProvider

GetMeterProvider returns the global MeterProvider. This allows users to use OTel SDK for custom metrics if they choose to.

func NewBridge

func NewBridge() sdkmetric.Producer

NewBridge creates a new OTel Metric Producer that bridges existing Prometheus metrics. It collects from prometheus.DefaultGatherer.

func NewTracer

func NewTracer(opts ...Option) tracer.Tracer

NewTracer provides tracer for server access, addr and path is the scrape_configs for prometheus server.

func SetMeterProvider

func SetMeterProvider(mp *sdkmetric.MeterProvider)

SetMeterProvider sets the global MeterProvider.

Types

type MetricMiddleware

type MetricMiddleware struct {
	// contains filtered or unexported fields
}

MetricMiddleware serves the /metrics endpoint for Prometheus scraping.

func NewMetricMiddleware

func NewMetricMiddleware(path string, provider *Provider) *MetricMiddleware

NewMetricMiddleware creates a new middleware that serves the /metrics endpoint. If provider has a MetricsHandler (OTel Prometheus Exporter), it uses that. Otherwise, falls back to the default promhttp.Handler() for compatibility.

func (*MetricMiddleware) ServeHTTP

func (m *MetricMiddleware) ServeHTTP(ctx context.Context, c *app.RequestContext)

ServeHTTP handles the /metrics endpoint requests.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option defines the configuration options for the metrics tracer.

func WithDisableServer

func WithDisableServer(disable bool) Option

WithDisableServer disable prometheus server

func WithEnableGoCollector

func WithEnableGoCollector(enable bool) Option

WithEnableGoCollector enable go collector

func WithGoCollectorRule

func WithGoCollectorRule(rules ...collectors.GoRuntimeMetricsRule) Option

WithGoCollectorRule define your custom go collector rule

func WithHistogramBuckets

func WithHistogramBuckets(buckets []float64) Option

WithHistogramBuckets define your custom histogram buckets base on your biz

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider holds the MeterProvider and associated resources.

func NewProvider

func NewProvider(ctx context.Context, metricsOpts config.MetricsOptions) (*Provider, error)

NewProvider creates a new metrics Provider with the configured exporters. It supports both Prometheus (pull) and OTLP (push) export modes simultaneously.

func (*Provider) MeterProvider

func (p *Provider) MeterProvider() *sdkmetric.MeterProvider

MeterProvider returns the underlying OTel MeterProvider.

func (*Provider) MetricsHandler

func (p *Provider) MetricsHandler() http.Handler

MetricsHandler returns the HTTP handler for /metrics endpoint.

func (*Provider) PrometheusOptions

func (p *Provider) PrometheusOptions() config.PrometheusOptions

PrometheusOptions returns the Prometheus configuration options.

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the MeterProvider.

Jump to

Keyboard shortcuts

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