rust-prometheus icon indicating copy to clipboard operation
rust-prometheus copied to clipboard

How to set histogram data

Open loony-bean opened this issue 5 years ago • 3 comments

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?

loony-bean avatar Nov 02 '19 19:11 loony-bean

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.

mxinden avatar May 25 '20 16:05 mxinden

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 avatar Nov 05 '20 22:11 alpire

@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?

mxinden avatar Nov 12 '20 09:11 mxinden