prom

package module
v0.0.0-...-2cf0550 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2017 License: MIT Imports: 5 Imported by: 0

README

counters

A collection of high-performance prometheus counters.

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

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) Inc

func (fpg *FixedPrecisionGauge) Inc()

Inc adds 1 to the counter.

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.

func (*FixedPrecisionGauge) Write

func (fpg *FixedPrecisionGauge) Write(out *dto.Metric) error

Write is implemented to be useful as a prometheus counter.

Jump to

Keyboard shortcuts

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