aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-27 16:05:12 +0100
committerKim Alvefur <zash@zash.se>2021-12-27 16:05:12 +0100
commit079a39c216927fefa0b5898e6dd4a8795d09764e (patch)
treed9a01d278df7da2371ec0c1af4f8ba7de4cc7232
parent569df0581e4d61e40ad032ccfc1c42deb2cf0516 (diff)
downloadprosody-079a39c216927fefa0b5898e6dd4a8795d09764e.tar.gz
prosody-079a39c216927fefa0b5898e6dd4a8795d09764e.zip
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.
-rw-r--r--util/statistics.lua2
-rw-r--r--util/statsd.lua2
2 files changed, 2 insertions, 2 deletions
diff --git a/util/statistics.lua b/util/statistics.lua
index b76a7385..cb6481c5 100644
--- a/util/statistics.lua
+++ b/util/statistics.lua
@@ -102,7 +102,7 @@ end
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
diff --git a/util/statsd.lua b/util/statsd.lua
index b91e2a79..6ae85c31 100644
--- a/util/statsd.lua
+++ b/util/statsd.lua
@@ -115,7 +115,7 @@ end
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
self._impl:push_counter_delta(bucket._full_name, 1)
end