Closed dzmitry-lahoda closed 1 year ago
No, it does not.
This is an intentional choice to ensure that counters are monotonically increasing, which would not be guaranteed if floating-point values were accepted, as negative values could be given, leading to the overall counter value decreasing.
If floating-point values are desired, gauges can be used instead, as helpers such as increment_gauge
already exist for working with gauges in a similar way to counters.
hm. gauge is awesome. will use. it is for tracking some long lived entity (in my case account).
but how to use gauge to track transfers? it may be huge amount gagues.
is any paper on itsq equivalence?
@tobz may you reconsdier you opinion?
ok, seem I do not care. so imho also can https://github.com/hydrogen602/unsigned-f64
This is an intentional choice to ensure that counters are monotonically increasing, which would not be guaranteed if floating-point values were accepted, as negative values could be given, leading to the overall counter value decreasing.
If floating-point values are desired, gauges can be used instead, as helpers such as
increment_gauge
already exist for working with gauges in a similar way to counters.
Guaranteeing positive values at the type-level is nice, however using a gauge and pretending it's a counter is not ideal. Prometheus has builtin features to deal with counter resets that are not available for gauge metric types (e.g. you cannot use the rate()
function).
So in order to record total request times, you'd have to either:
deriv()
on the gauge, but this won't account for resetsThese hacks could be avoided either by:
f64
counters, and clipping new values below 0
(or do nothing and leave negative values as a responsibility of the user)@tamasfe It's unfortunate that our choice to constrain counters to u64
has suboptimal interactions with that aspect of Prometheus, but it's not something I'm ever going to change in metrics
.
If people are primarily interacting with Prometheus, and want an experience that matches the Prometheus conventions more closely, both the prometheus
and prometheus-client
crates are suitable replacements for metrics
.
We've just switched from prometheus
to use metrics
due to the convenient API and the architecture and philosophy that is similar to tracing
. I was confident that this issue could be easily resolved or worked around as the most (only?) widely used exporter seems to target Prometheus.
that matches the Prometheus conventions more closely
It's not just Prometheus, OpenTelemetry also recently chose to recommend seconds as the unit of measurement for durations after a long debate.
but it's not something I'm ever going to change in metrics.
I'd be happy to submit a PR for it.
as i see openmetrics are u64 or f64 https://github.com/OpenObservability/OpenMetrics/issues/262 .
for me allow f64 in counter! and may be casting u128 to f64 behind scenes is good option to try to support fintech/crypto domains