prometheus/model
beorn7 a7c519930e histograms: Add Compact method to the normal integer Histogram
And use the new method to call to compact Histograms during
parsing. This happens for both `Histogram` and `FloatHistogram`. In
this way, if targets decide to optimize the exposition size by merging
spans with empty buckets in between, we still get a normalized
results. It will also normalize away any valid but weird
representations like empty spans, spans with offset zero, and empty
buckets at the start or end of a span.

The implementation seemed easy at first as it just turns the
`compactBuckets` helper into a generic function (which now got its own
file). However, the integer Histograms have delta buckets instead of
absolute buckets, which had to be treated specially in the generic
`compactBuckets` function. To make sure it works, I have added plenty
of explicit tests for `Histogram` in addition to the `FloatHistogram`
tests.

I have also updated the doc comment for the `Compact` method.

Based on the insights now expressed in the doc comment, compacting
with a maxEmptyBuckets > 0 is rarely useful. Therefore, this commit
also sets the value to 0 in the two cases we were using 3 so far. We
might still want to reconsider, so I don't want to remove the
maxEmptyBuckets parameter right now.

Signed-off-by: beorn7 <beorn@grafana.com>
2022-09-27 13:04:16 +02:00
..
exemplar Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
histogram histograms: Add Compact method to the normal integer Histogram 2022-09-27 13:04:16 +02:00
labels labels: add a test for JSON and YAML marshalling 2022-08-03 11:18:02 +02:00
metadata Introduce TSDB changes for appending metadata to the WAL (#10972) 2022-07-19 10:58:52 +02:00
relabel refactor (package model): move from github.com/pkg/errors to 'errors' and 'fmt' packages (#10747) 2022-06-27 21:29:19 +02:00
rulefmt Merge pull request #10893 from prymitive/unwrap_errors 2022-06-30 11:30:21 +02:00
textparse histograms: Add Compact method to the normal integer Histogram 2022-09-27 13:04:16 +02:00
timestamp Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
value Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00