stats.Gauge
Description
Gauge metric.
Gauge is one of a few types of metrics supported by the stats system. It reflects a fluctuating value that is usually sampled at a regular frequency. Once you've created one, it becomes visible to the stats system, and its current value can be queried via admin port under the endpoint GET /metrics in Prometheus exposition formats.
You create a Gauge by a name, optionally providing label names if it has sub-metrics.
pipy({_gauge: new stats.Gauge('concurrency', ['peer'])})
Metric names starting with pipy_ are reserved for internal use.
After that, you change the metric value by set().
_gauge.set(100)
You can also access a sub-metric by giving values to the labels. The label values must be given in the order they appear in the construction.
_gauge.withLabels('127.0.0.1').set(3)
Constructor
new stats.Gauge(name, labelNames?)
Creates an instance of Gauge.
Methods
decrease(n?)
Decreases the current value by a number.
increase(n?)
Increases the current value by a number.
set(n)
Sets the current value.
withLabels(...labels)
Retrieves a sub-metric by labels.
zero()
Sets the current value to zero.