Repository navigation
Conversation
Histogram leaves out _sum when its lowest bucket is negative, since OpenMetrics 1.0 doesn't allow a sum there. MultiProcessCollector builds its own histogram samples and kept the _sum from the mmap files, so the same histogram exposed an extra series in multiprocess mode. Drop _sum on the accumulate path when the lowest bucket bound is negative. merge(accumulate=False) still returns the raw value. Signed-off-by: Haegan McGarry <haeganm@gmail.com>
csmarchbanks
left a comment
There was a problem hiding this comment.
Since OM 2.0 is adding sum back in everywhere I would learn towards at lest keeping it in the samples. That said, we should probably filter it out in exposition for at least OM 1.0 users.
OpenMetrics 2.0 wants a sum on every histogram, so Histogram now keeps _sum even when the lowest bucket is negative, and multiprocess goes back to keeping it too. OpenMetrics 1.0 doesn't allow a sum with negative buckets, so generate_latest drops _sum for those histograms when the version is below 2.0.0. Signed-off-by: Haegan McGarry <haeganm@gmail.com>
|
makes sense, flipped it in ca715c8. one side effect, the classic text format now shows one more thing on 1.0: its text format says |
Histogramleaves out_sumwhen its lowest bucket is negative, since OpenMetrics 1.0 says a histogram with negative buckets MUST NOT contain a sum.MultiProcessCollectornever did that check, so in multiprocess mode the same histogram still had a_sum, OM 1.0 output included:OpenMetrics 2.0 goes the other way (every histogram has count and sum), so per review this keeps
_sumin the samples everywhere and filters it at exposition instead:Histogramalways emits_sumopenmetrics.exposition.generate_latestdrops_sumfor histograms with a negative bucket whenversionis below 2.0.0side effect: the classic text format now shows
_sumfor these histograms in single process too.test_histogram_negative_bucketsintests/test_multiprocess.pyfails on master (b'h_sum' unexpectedly foundin the OM 1.0 output) and passes here, and the OM exposition test now checks that 1.0 leaves_sumout and 2.0 keeps it. full suite passes on 3.12 (Windows), and flake8, isort and mypy are clean.@csmarchbanks