Repository navigation
Drop negative-bucket histogram _sum and _count only in OpenMetrics 1.0 output - #1254
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 <[email protected]>
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 <[email protected]>
|
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 |
|
I'm good with keeping I would say let's drop We need to make the parser 2.0 compliant still so no worries about that not working yet. |
OpenMetrics 1.0 only allows _count on a histogram when it has a _sum,
so dropping just _sum left output that this library's own OpenMetrics
parser rejects ("_sum/_gsum must be present if _count is present").
Drop both, like HistogramMetricFamily already does. The +Inf bucket
still has the count.
Also write a custom bucket with a malformed le out as is, instead of
failing the whole OpenMetrics 1.0 output.
Signed-off-by: Haegan McGarry <[email protected]>
|
sounds good! dropped also, since the 1.0 path parses updated the title and description to match. thanks for the quick reviews! |
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
_suminHistogram's samples (single and multiprocess) and filters it at exposition instead:Histogramalways emits_sumopenmetrics.exposition.generate_latestdrops_sumand_countfor histograms with a negative bucket whenversionis below 2.0.0, since 1.0 only allows_countalongside a sum (same asHistogramMetricFamily)behavior changes: OM 1.0 scrapes no longer have
_countfor these, and multiprocess ones lose_sumtoo (the+Infbucket still has the count). 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 out_sumand_count(and parses with the library's OM parser) while 2.0 keeps both. full suite passes on 3.12 (Windows), and flake8, isort and mypy are clean.@csmarchbanks