metricshelper

package
v0.0.0-...-c101335 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterOrLogError

func RegisterOrLogError(logger commontypes.Logger,
	registerer prometheus.Registerer,
	collector prometheus.Collector,
	name string,
)

Types

type LazyGauge

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

LazyGauge registers its underlying Gauge the first time Set is called. This avoids exposing a default zero value before we have an appropriate value to expose.

func NewLazyGauge

func NewLazyGauge(
	registerer prometheus.Registerer,
	logger commontypes.Logger,
	opts prometheus.GaugeOpts,
) *LazyGauge

func (*LazyGauge) Set

func (g *LazyGauge) Set(value float64)

func (*LazyGauge) Unregister

func (g *LazyGauge) Unregister() bool

Unregister must be used instead of prometheus.Registerer.Unregister. Otherwise, it would be possible for the LazyGauge to have never been Set and thus registered, and then after invocation of prometheus.Registerer.Unregister, the next Set would cause the gauge to be registered, which is almost definitely unexpected behavior. In fact, LazyGauge intentionally does not implement prometheus.Collector to avoid confusion. The meaning of the return value matches that of prometheus.Registerer.Unregister.

type PrometheusRegistererWrapper

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

func NewPrometheusRegistererWrapper

func NewPrometheusRegistererWrapper(registerer prometheus.Registerer, logger commontypes.Logger) *PrometheusRegistererWrapper

func (*PrometheusRegistererWrapper) MustRegister

func (prw *PrometheusRegistererWrapper) MustRegister(collectors ...prometheus.Collector)

func (*PrometheusRegistererWrapper) Register

func (prw *PrometheusRegistererWrapper) Register(collector prometheus.Collector) error

func (*PrometheusRegistererWrapper) Unregister

func (prw *PrometheusRegistererWrapper) Unregister(collector prometheus.Collector) bool

Jump to

Keyboard shortcuts

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