From 939c30da5f724e7b2d2d0263bf74323ca7431c2d Mon Sep 17 00:00:00 2001 From: Martin Michaelis Date: Tue, 16 Feb 2021 21:06:50 +0100 Subject: [PATCH] stats: openmentrics: Change histogram bucket unit to seconds In ae678116a79fff609cdf4fb1eb7eb3db2975bf1c the unit of durations was changed from microseconds to seconds, but the `le` field in histograms is still in microseconds. --- src/stats/stats-service-openmetrics.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stats/stats-service-openmetrics.c b/src/stats/stats-service-openmetrics.c index 56c35dd022..83832a3160 100644 --- a/src/stats/stats-service-openmetrics.c +++ b/src/stats/stats-service-openmetrics.c @@ -198,8 +198,10 @@ openmetrics_export_histogram_bucket(struct openmetrics_request *req, } if (bucket_limit == INTMAX_MAX) str_append(out, "le=\"+Inf\""); - else - str_printfa(out, "le=\"%jd\"", bucket_limit); + else { + /* Convert from microseconds to seconds */ + str_printfa(out, "le=\"%.6f\"", bucket_limit/1e6F); + } str_printfa(out, "} %"PRIu64"\n", count); } -- 2.47.3