Comparison

util/statistics.lua @ 12123:7ba686696250

openmetrics/histograms: fix incorrect condition for bucketing The buckets thresholds are to be taken as "less than or equal to". The condition as written in the code did only "less than", not "less than or equal to". That's fixed now.
author Jonas Schäfer <jonas@wielicki.name>
date Sun, 26 Dec 2021 22:32:00 +0100
parent 11523:5f15ab7c6ae5
child 12124:7d985e5bc1fb
comparison
equal deleted inserted replaced
12122:50795249b7be 12123:7ba686696250
100 end 100 end
101 101
102 function histogram_metric_mt:sample(value) 102 function histogram_metric_mt:sample(value)
103 -- According to the I-D, values must be part of all buckets 103 -- According to the I-D, values must be part of all buckets
104 for i, bucket in pairs(self) do 104 for i, bucket in pairs(self) do
105 if "number" == type(i) and bucket.threshold > value then 105 if "number" == type(i) and bucket.threshold >= value then
106 bucket.count = bucket.count + 1 106 bucket.count = bucket.count + 1
107 end 107 end
108 end 108 end
109 self._sum = self._sum + value 109 self._sum = self._sum + value
110 self._count = self._count + 1 110 self._count = self._count + 1