Help us shape the future of Go! Take the 2026 Go Developer Survey

prometheus

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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

Provider wraps a metrics.Metrics provider with a Prometheus registry that can instrument the HTTP server's handlers.

func New

func New(inner metrics.Metrics, logger loggerFunc, httpRequestBuckets []float64) *Provider

New returns a new Provider object.

func (*Provider) All

func (p *Provider) All() map[string]any

All returns the union of the inner metric provider and the underlying prometheus registry.

func (*Provider) Clear

func (p *Provider) Clear()

Clear resets the inner metric provider. The Prometheus registry does not expose an interface to clear the metrics so this call has no affect on metrics tracked by Prometheus.

func (*Provider) Counter

func (p *Provider) Counter(name string) metrics.Counter

Counter returns a named counter.

func (*Provider) Histogram

func (p *Provider) Histogram(name string) metrics.Histogram

Histogram returns a named histogram.

func (*Provider) Info

func (*Provider) Info() metrics.Info

Info returns attributes that describe the metric provider.

func (*Provider) InstrumentHandler

func (p *Provider) InstrumentHandler(handler http.Handler, label string) http.Handler

InstrumentHandler returned wrapped HTTP handler with added prometheus instrumentation

func (*Provider) MarshalJSON

func (p *Provider) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON representation of the unioned metrics.

func (*Provider) MustRegister

func (p *Provider) MustRegister(cs ...prometheus.Collector)

MustRegister register the collectors on OPA prometheus registry and panics when an error occurs

func (*Provider) Register

func (p *Provider) Register(c prometheus.Collector) error

Register register the collectors on OPA prometheus registry

func (*Provider) RegisterEndpoints

func (p *Provider) RegisterEndpoints(registrar func(path, method string, handler http.Handler))

RegisterEndpoints registers `/metrics` endpoint

func (*Provider) Timer

func (p *Provider) Timer(name string) metrics.Timer

Timer returns a named timer.

func (*Provider) Unregister

func (p *Provider) Unregister(c prometheus.Collector) bool

Unregister unregister the collectors on OPA prometheus registry

Jump to

Keyboard shortcuts

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