Diff

util/statistics.lua @ 12124:7d985e5bc1fb

openmetrics/histograms: improve code clarity If buckets thresholds are to be taken as "less than or equal to", then using the less than or equal to operator seems sensible.
author Kim Alvefur <zash@zash.se>
date Mon, 27 Dec 2021 16:05:12 +0100
parent 12123:7ba686696250
child 12975:d10957394a3c
line wrap: on
line diff
--- a/util/statistics.lua	Sun Dec 26 22:32:00 2021 +0100
+++ b/util/statistics.lua	Mon Dec 27 16:05:12 2021 +0100
@@ -102,7 +102,7 @@
 function histogram_metric_mt:sample(value)
 	-- According to the I-D, values must be part of all buckets
 	for i, bucket in pairs(self) do
-		if "number" == type(i) and bucket.threshold >= value then
+		if "number" == type(i) and value <= bucket.threshold then
 			bucket.count = bucket.count + 1
 		end
 	end