From 49c5b1fae4ae6500864fe8ae6bb6ac0eae085bbb Mon Sep 17 00:00:00 2001 From: beorn7 Date: Wed, 25 Jan 2023 18:23:10 +0100 Subject: [PATCH] histograms: Fix counter reset header during merging See detailed discussion: https://github.com/prometheus/prometheus/pull/11864#issuecomment-1403963451 Signed-off-by: beorn7 --- storage/merge.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/storage/merge.go b/storage/merge.go index c5768c765..8db1f7ae8 100644 --- a/storage/merge.go +++ b/storage/merge.go @@ -533,8 +533,12 @@ func (c *chainSampleIterator) AtFloatHistogram() (int64, *histogram.FloatHistogr } t, fh := c.curr.AtFloatHistogram() // If the current sample is not consecutive with the previous one, we - // cannot be sure anymore that there was no counter reset. - if !c.consecutive && fh.CounterResetHint == histogram.NotCounterReset { + // cannot be sure anymore about counter resets for counter histograms. + // TODO(beorn7): If a `NotCounterReset` sample is followed by a + // non-consecutive `CounterReset` sample, we could keep the hint as + // `CounterReset`. But then we needed to track the previous sample + // in more detail, which might not be worth it. + if !c.consecutive && fh.CounterResetHint != histogram.GaugeType { fh.CounterResetHint = histogram.UnknownCounterReset } return t, fh