rust-prometheus
rust-prometheus copied to clipboard
How to set histogram data
Hi!
The data I'd like to put into Histogram
comes in aggregated form. This includes bucket bounds, counts, sum and total count. I do not have individual observations, and cannot use observe
unfortunately.
Is is possible to create a new (or maybe reset existing) Histogram
metric with already aggregated data?
One rather obscure solution in case performance does not matter would be to replay the observations into a fresh Histogram each time one gets a hold of the aggregated form.
As of today I am not sure enabling users to manipulate the Histogram values manually is worth the introduced complexity.
This would be helpful to output pre-collected data in the prometheus format. Would you be open to a PR adding a pub fn observe_many(&self, v: f64, n: usize)
method to Histogram
?
@alpire as elaborated above I don't think this special case is worth the additional complexity. Would a custom type implementing the Collector
interface work for you?