A gauge that is registered but does not have a value set is currently set to 0 (zero). I believe this behavior to be incorrect because a gauge without a label does not work like it.
const client = require('prom-client');
const gauge = new client.Gauge({ name: 'metric_name', help: 'metric_help', labelNames: ['example'] });
const gauge2 = new client.Gauge({ name: 'metric_name2', help: 'metric_help2' });
console.log(await client.register.metrics())
gauge.set({ example: 'true' }, 1)
console.log(await client.register.metrics())
gauge.reset();
console.log(await client.register.metrics())
Output 1 after initialization:
# HELP metric_name metric_help
# TYPE metric_name gauge
# HELP metric_name2 metric_help2
# TYPE metric_name2 gauge
metric_name2 0
Output 2 after setting gauge:
# HELP metric_name metric_help
# TYPE metric_name gauge
metric_name{example="true"} 1
# HELP metric_name2 metric_help2
# TYPE metric_name2 gauge
metric_name2 0
Output 3 after reset:
# HELP metric_name metric_help
# TYPE metric_name gauge
# HELP metric_name2 metric_help2
# TYPE metric_name2 gauge
metric_name2 0
I would expect the output 1 of both gauges to be the same and instead of a default of 0 having a default of undefined.
A gauge that is registered but does not have a value set is currently set to 0 (zero). I believe this behavior to be incorrect because a gauge without a label does not work like it.
Output 1 after initialization:
Output 2 after setting gauge:
Output 3 after reset:
I would expect the output 1 of both gauges to be the same and instead of a default of 0 having a default of undefined.