Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
12123:7ba686696250 | 12124:7d985e5bc1fb |
---|---|
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 value <= bucket.threshold 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 |