Documentation
¶
Overview ¶
Package ewma provides an implementation of an exponentially weighted moving average (EWMA) that can be reported as a Prometheus metric.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EWMA ¶
type EWMA struct {
// contains filtered or unexported fields
}
EWMA provides an exponentially weighted moving average (EWMA). EWMA implements prometheus.Collector.
func New ¶
New creates a new EWMA with the given options and source. The returned EWMA must be started by calling EWMA.Monitor.
func (*EWMA) Collect ¶
func (ewma *EWMA) Collect(ch chan<- prometheus.Metric)
Collect writes the EWMA metrics to the given channel. Metrics are only written when the EWMA is running via EWMA.Monitor.
func (*EWMA) Describe ¶
func (ewma *EWMA) Describe(ch chan<- *prometheus.Desc)
Describe describes the metrics emitted by EWMA.
type Options ¶
type Options struct {
// Name of the EWMA metric.
Name string
// Help text for the EWMA metric.
Help string
// UpdateFrequency is the frequency at which the EWMA is updated from the
// Source. A typical value is 5s.
UpdateFrequency time.Duration
// Windows is a list of time windows for which averages will be calculated;
// such as 1m, 5m, and 15m averages.
Windows []time.Duration
}
Options provides configuration options for an EWMA.
type Source ¶
type Source interface {
// Get returns the current value for the EWMA calculation.
Get() float64
}
Source is an interface that provides a value for an EWMA calculation.
type SourceFunc ¶
type SourceFunc func() float64
SourceFunc is a Source that provides its value from a function.
func (SourceFunc) Get ¶
func (sf SourceFunc) Get() float64
Get returns the value provided by the SourceFunc.