-
Notifications
You must be signed in to change notification settings - Fork 2
MetroMan Gauge
GitHub Actions edited this page Aug 24, 2026
·
4 revisions
An up/down value — set to any number, then increment and decrement freely.
Reach for Gauge when the value can go both up and down — queue
depth, in-flight connections, memory in use, temperature. For
monotonically-increasing counts, use Counter.
import { Gauge } from '@tundralibs/metro-man';
const queue = new Gauge({ name: 'queue_depth' });
queue.set(0);
queue.inc({ priority: 'high' });
queue.inc({ priority: 'high' });
queue.dec({ priority: 'high' });Parameters:
-
options.name— Required. Metric identifier; must match/^[a-zA-Z_:][a-zA-Z0-9_:]*$/(Prometheus name rules). -
options.help— Optional. Human description.
Throws:
-
InvalidMetricOptionsError— Whennameis missing, not a string, or doesn't match/^[a-zA-Z_:][a-zA-Z0-9_:]*$/; or whenhelpis given but not a string.
Replace the named series with value.
Throws:
-
InvalidMetricOptionsError— whenvalueis non-finite (NaN,±Infinity). -
InvalidLabelError— whenlabelscontains a name outside[A-Za-z_][A-Za-z0-9_]*.
Adjust the named series. Series default to 0 if absent. Overloads:
-
inc()/dec()— ±1 on unlabelled -
inc(labels)/dec(labels)— ±1 on labelled -
inc(amount)/dec(amount)— ±amounton unlabelled -
inc(amount, labels)/dec(amount, labels)— ±amounton labelled
Throws:
-
InvalidMetricOptionsError— whenamountis non-finite. -
InvalidLabelError— whenlabelscontains a name outside[A-Za-z_][A-Za-z0-9_]*.
reset() drops every series; remove(labels?) drops a single series
and returns true if a series was actually removed. Both inherited
from BaseMetric.
Throws:
-
InvalidLabelError—remove(labels)rejects a label name outside[A-Za-z_][A-Za-z0-9_]*, the same validationset/inc/decapply.
Inherited from BaseMetric.
# HELP queue_depth
# TYPE queue_depth gauge
queue_depth 0
queue_depth{priority="high"} 1
{
"name": "queue_depth",
"help": "",
"type": "GAUGE",
"labels": ["priority"],
"data": {
"no_label": 0,
"priority=\"high\"": 1
}
}