stats.Counter
Description
Counter metric.
Counter is one of a few types of metrics supported by the stats system, and it is the simplest one, which is just a monotonic increasing number. 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 Counter by a name, optionally providing label names if it has sub-metrics.
pipy({_counter: new stats.Counter('http_requests', ['method', 'status'])})
Metric names starting with pipy_ are reserved for internal use.
After that, you increase the metric value by increase().
_counter.increase()
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.
_counter.withLabels('GET').increase()_counter.withLabels('GET', 200).increase()
Constructor
new stats.Counter(name, labelNames?)
Creates an instance of Counter.
Methods
decrease(n?)
Decreases the current value by a number.
increase(n?)
Increases the current value by a number.
withLabels(...labels)
Retrieves a sub-metric by labels.
zero()
Sets the current value to zero.