# HG changeset patch # User Kim Alvefur # Date 1640617512 -3600 # Node ID 7d985e5bc1fbc707ce8d3cc9dd44c3df83416883 # Parent 7ba68669625000560700ae9ffe302b121ba9e637 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. diff -r 7ba686696250 -r 7d985e5bc1fb util/statistics.lua --- 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 diff -r 7ba686696250 -r 7d985e5bc1fb util/statsd.lua --- a/util/statsd.lua Sun Dec 26 22:32:00 2021 +0100 +++ b/util/statsd.lua Mon Dec 27 16:05:12 2021 +0100 @@ -115,7 +115,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 self._impl:push_counter_delta(bucket._full_name, 1) end