Software /
code /
prosody
Comparison
util/statsd.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 | 12387:05c250fa335a |
comparison
equal
deleted
inserted
replaced
12123:7ba686696250 | 12124:7d985e5bc1fb |
---|---|
113 end | 113 end |
114 | 114 |
115 function histogram_metric_mt:sample(value) | 115 function histogram_metric_mt:sample(value) |
116 -- According to the I-D, values must be part of all buckets | 116 -- According to the I-D, values must be part of all buckets |
117 for i, bucket in pairs(self) do | 117 for i, bucket in pairs(self) do |
118 if "number" == type(i) and bucket.threshold >= value then | 118 if "number" == type(i) and value <= bucket.threshold then |
119 bucket.count = bucket.count + 1 | 119 bucket.count = bucket.count + 1 |
120 self._impl:push_counter_delta(bucket._full_name, 1) | 120 self._impl:push_counter_delta(bucket._full_name, 1) |
121 end | 121 end |
122 end | 122 end |
123 self._sum = self._sum + value | 123 self._sum = self._sum + value |