Documentation ¶
Overview ¶
Package metrics wraps prometheus.Metrics making it a bit easier to manage counters and gauges and also providing a mechanism by which all changes are communicated out via channels.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CountChange ¶ added in v0.0.2
CountChange represents a change to counter. This instance contains the increment, not the resulting value.
type Counter ¶ added in v0.0.2
type Counter interface { // Inc increments the counter by 1. Use Add to increment it by arbitrary // non-negative values. Inc() // Add adds the given value to the counter. It panics if the value is < // 0. Add(float64) }
Counter is a Metric that represents a single numerical value that only ever goes up.
type Gauge ¶ added in v0.0.2
type Gauge interface { // Set sets the Gauge to an arbitrary value. Set(float64) // Inc increments the Gauge by 1. Use Add to increment it by arbitrary // values. Inc() // Dec decrements the Gauge by 1. Use Sub to decrement it by arbitrary // values. Dec() // Add adds the given value to the Gauge. (The value can be negative, // resulting in a decrease of the Gauge.) Add(float64) // Sub subtracts the given value from the Gauge. (The value can be // negative, resulting in an increase of the Gauge.) Sub(float64) }
Gauge is a Metric that represents a single numerical value that can arbitrarily go up and down.
type GaugeChange ¶ added in v0.0.2
GaugeChange represents a change to a gauge. This instance contains the value that the gauge was changed by, not the resulting value.
type Metrics ¶
type Metrics interface { // Counter returns a counter for the given name and labels. Is useful in situation where the counter should be // increases by some other value that 1. Counter(name string, constLabels map[string]string) Counter // IncCounter increases the counter with the given name and labels by 1. IncCounter(name string, constLabels map[string]string) // Gauge returns a gauge with the given name. Gauge(name string) Gauge // SetGauge sets the given value in the gauge with the given name. SetGauge(name string, v int) }
Metrics provides the concrete abstraction used by clients of this package.
type Option ¶ added in v0.0.2
type Option func(collector *optionsCollector)
Option for configuring this package.
func WithOutputChannels ¶ added in v0.0.2
func WithOutputChannels(countChan chan<- CountChange, gaugeChan chan<- GaugeChange) Option
WithOutputChannels sets channels which will trigger whenever a counter of gauge is altered. This feature is meant for testing purposes.