beam-telemetry / telemetry_metrics_prometheus_core

Core Prometheus Telemetry.Metrics Reporter package for telemetry_metrics_prometheus
Apache License 2.0
35 stars 30 forks source link

Initialising counter metrics #53

Open bernardd opened 1 year ago

bernardd commented 1 year ago

Please forgive me if this is a dumb question - I'm still learning my way around metrics in general and Prometheus in particular.

Would it make sense to have, at least as an option, the ability to initialise counter metrics to 0 when they're first set up? As it stands (if my reading of things is correct), they'll return a null value until the first time they're incremented. That leads to a not-entirely-intuitive result when later you're using the increase function in PromQL and the very first event doesn't count because there's no "increase" between null and 1.

MzudemO commented 6 months ago

Seconding this, as it is also recommended by Prometheus https://prometheus.io/docs/practices/instrumentation/#avoid-missing-metrics

The issue here is it isn't possible to know (at supervisor start) which counters to initialize because you can have arbitrary values in tags, where each new tag value creates a new counter. I'm not sure if sending a 0 event first when encountering the initial 1 for a counter would help in PromQL?