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 ¶
NewBridge creates a new OTel Metric Producer that bridges existing Prometheus metrics. It collects from prometheus.DefaultGatherer.
func NewTracer ¶
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 ¶
WithDisableServer disable prometheus server
func WithEnableGoCollector ¶
WithEnableGoCollector enable go collector
func WithGoCollectorRule ¶
func WithGoCollectorRule(rules ...collectors.GoRuntimeMetricsRule) Option
WithGoCollectorRule define your custom go collector rule
func WithHistogramBuckets ¶
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 ¶
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 ¶
MetricsHandler returns the HTTP handler for /metrics endpoint.
func (*Provider) PrometheusOptions ¶
func (p *Provider) PrometheusOptions() config.PrometheusOptions
PrometheusOptions returns the Prometheus configuration options.