haskell-github-trust / ekg-core

Library for tracking system metrics
BSD 3-Clause "New" or "Revised" License
40 stars 39 forks source link

Fix distribution min/max #44

Closed EggBaconAndSpam closed 7 months ago

EggBaconAndSpam commented 3 years ago

Previously the min/max returned by read :: Distribution -> IO Stats would always be equal to the values recorded in the last stripe, due to an incorrect bugfix (see commit 813aa426be78e8abcf1c7cdd43433bcffa07828e). We can fix the original bug (as well as the current incarnation) by properly initialising new distributions with the unit elements of the corresponding monoids (inf for min and -inf for max).

For context: the max of a distribution we added to our program was always returning 0 before this fix:

The max of the distribution previously: image

The sum (to prove that the distribution isn't actually 0): image

The max after applying this PR (ignore the spurious 0s, that's an unrelated issue): image