Closed tyranron closed 1 year ago
Thanks for the PR, but please do note that in the larger Prometheus ecosystem by design Counters do not provide a set()
method. They are meant to only increment, or to reset back to 0 in very rare cases.
You can read more about that at https://www.robustperception.io/setting-a-prometheus-counter/ and https://www.robustperception.io/how-does-a-prometheus-counter-work/.
This was already discussed in https://github.com/tikv/rust-prometheus/pull/303 with enough consensus, as such I'm closing this PR.
Synopsis
I've written the
metrics-prometheus
crate, trying to pave the way for uniting ecosystems ofprometheus
andmetrics
crates. While being somewhat complete, there are still minor issues which I cannot resolve (at least I didn't find a way) without making contributions to upstream.One of them is that
metrics::CounterFn
interface providesabsolute()
operation, whileprometheus::GenericCounter
's API doesn't provide a way to implement it atomically.Solution
This PR adds
GenericCounter::set()
operation, allowing to cover this use case.Checklist