histogram_metrics_helper: support native histogram
approx_exponential_histogram uses similar logic to Prometheus native histogram, to allow Prometheus sending its data in a native histogram format it needs to report schema and min id (id of the first bucket). This patch update to_metrics_histogram to set those optional parameters, leaving it to the Prometheus to decide in what format the histogram will be reported. Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
@@ -19,10 +19,12 @@
|
||||
template<uint64_t Min, uint64_t Max, size_t Precision>
|
||||
seastar::metrics::histogram to_metrics_histogram(const utils::approx_exponential_histogram<Min, Max, Precision>& hist) {
|
||||
seastar::metrics::histogram res;
|
||||
static constexpr size_t MIN_ID = log2ceil(Min) * Precision + 1;
|
||||
static constexpr size_t Schema = log2floor(Precision);
|
||||
res.buckets.resize(hist.size() - 1);
|
||||
uint64_t cummulative_count = 0;
|
||||
res.sample_sum = 0;
|
||||
|
||||
res.native_histogram = seastar::metrics::native_histogram_info{Schema, MIN_ID};
|
||||
for (size_t i = 0; i < hist.NUM_BUCKETS - 1; i++) {
|
||||
auto& v = res.buckets[i];
|
||||
v.upper_bound = hist.get_bucket_lower_limit(i + 1);
|
||||
|
||||
Reference in New Issue
Block a user