userver-framework/userver

Export observed histogram values sum into prometheus

DmitriyH opened this issue · 0 comments

Currently, Histogram doesn't have a method to get the observed values sum.
And when it is exported into prometheus format, _sum is absent.

For example:

userver::utils::statistics::Histogram test_histogram{std::vector<double>{1.0, 5.0, 10.0}};

test_metrics_test_histogram_bucket{le="1"} 2
test_metrics_test_histogram_bucket{le="5"} 6
test_metrics_test_histogram_bucket{le="10"} 11
test_metrics_test_histogram_bucket{le="+Inf"} 50
test_metrics_test_histogram_count{} 50

If the same histogram would be constructed from prometheus library, it would have additional line:

test_metrics_test_histogram_sum{} 1225

Value _sum is a standard part of prometheus histogram: https://prometheus.io/docs/concepts/metric_types/#histogram

It would be useful, if _sum will be implemented for prometheus histogram export.