Documentation ¶
Overview ¶
Package prom exports a collection of prometheus.Metrics that use int64 and atomic store and add for maximum speed.
In testing it provides a 10x speedup compared to github.com/prometheus/client_golang/prometheus.Metrics.
Index ¶
- func NewCounter(opts prometheus.CounterOpts, prec uint) prometheus.Counter
- func NewGauge(opts prometheus.GaugeOpts, prec uint) prometheus.Gauge
- type FixedPrecisionCounter
- type FixedPrecisionGauge
- func (fpg *FixedPrecisionGauge) Add(delta float64)
- func (fpg *FixedPrecisionGauge) Collect(mc chan<- prometheus.Metric)
- func (fpg *FixedPrecisionGauge) Dec()
- func (fpg *FixedPrecisionGauge) Desc() *prometheus.Desc
- func (fpg *FixedPrecisionGauge) Describe(dc chan<- *prometheus.Desc)
- func (fpg *FixedPrecisionGauge) Inc()
- func (fpg *FixedPrecisionGauge) Set(val float64)
- func (fpg *FixedPrecisionGauge) SetToCurrentTime()
- func (fpg *FixedPrecisionGauge) Sub(val float64)
- func (fpg *FixedPrecisionGauge) Value() float64
- func (fpg *FixedPrecisionGauge) Write(out *dto.Metric) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCounter ¶
func NewCounter(opts prometheus.CounterOpts, prec uint) prometheus.Counter
NewCounter returns prometheus.Counter backed by a fixed-precision int64 that uses atomic operations.
func NewGauge ¶
func NewGauge(opts prometheus.GaugeOpts, prec uint) prometheus.Gauge
NewGauge returns prometheus.Gauge backed by a fixed-precision int64 that uses atomic operations.
Types ¶
type FixedPrecisionCounter ¶
type FixedPrecisionCounter struct {
FixedPrecisionGauge
}
FixedPrecisionCounter embeds FixedPrecisionGauge and enforces the same guarantees as a prometheus.Counter where negative adds panic.
func NewFixedPrecisionCounter ¶
func NewFixedPrecisionCounter(opts prometheus.CounterOpts, prec uint) *FixedPrecisionCounter
NewFixedPrecisionCounter creates a FixedPrecisionCounter based on the provided Opts. It matches prometheus.Counter behavior by panicking if adding negative numbers.
func (*FixedPrecisionCounter) Add ¶
func (fpc *FixedPrecisionCounter) Add(v float64)
Add adds the given value to the counter. It matches prometheus.Counter behavior by panicking if the value is < 0.
type FixedPrecisionGauge ¶
type FixedPrecisionGauge struct {
// contains filtered or unexported fields
}
FixedPrecisionGauge implements a prometheus Gauge/Counter metric that uses atomic adds and stores for speed.
func NewFixedPrecisionGauge ¶
func NewFixedPrecisionGauge(opts prometheus.GaugeOpts, prec uint) *FixedPrecisionGauge
NewFixedPrecisionGauge returns a populated fixed-precision counter.
func (*FixedPrecisionGauge) Add ¶
func (fpg *FixedPrecisionGauge) Add(delta float64)
Add generically adds delta to the value stored by counter.
func (*FixedPrecisionGauge) Collect ¶
func (fpg *FixedPrecisionGauge) Collect(mc chan<- prometheus.Metric)
Collect sends the counter value to the chan
func (*FixedPrecisionGauge) Dec ¶
func (fpg *FixedPrecisionGauge) Dec()
Dec decrements 1 from the counter.
func (*FixedPrecisionGauge) Desc ¶
func (fpg *FixedPrecisionGauge) Desc() *prometheus.Desc
Desc returns this FixedPrecisionGauge's prometheus description.
func (*FixedPrecisionGauge) Describe ¶
func (fpg *FixedPrecisionGauge) Describe(dc chan<- *prometheus.Desc)
Describe sends the counter's description to the chan
func (*FixedPrecisionGauge) Set ¶
func (fpg *FixedPrecisionGauge) Set(val float64)
Set stores the value in the counter.
func (*FixedPrecisionGauge) SetToCurrentTime ¶
func (fpg *FixedPrecisionGauge) SetToCurrentTime()
SetToCurrentTime sets the Gauge to the current Unix time in seconds.
Beware that if precision is set too high (greater than 9) it can overflow the underlying int64.
func (*FixedPrecisionGauge) Sub ¶
func (fpg *FixedPrecisionGauge) Sub(val float64)
Sub is the inverse of Add.
func (*FixedPrecisionGauge) Value ¶
func (fpg *FixedPrecisionGauge) Value() float64
Value returns a float64 representation of the current value stored.