From c8deefb038544a38308cc092d1d573bb09e36199 Mon Sep 17 00:00:00 2001 From: Minh Nguyen <148210689+pipiland2612@users.noreply.github.com> Date: Fri, 22 Aug 2025 00:26:01 +0300 Subject: [PATCH] [tsdb] Add CounterResetHint: CounterReset to synthetic zero sample (#17011) Signed-off-by: pipiland2612 --- tsdb/head_append.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tsdb/head_append.go b/tsdb/head_append.go index 24dd271453..a5d6e9127a 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -781,7 +781,10 @@ func (a *headAppender) AppendHistogramCTZeroSample(ref storage.SeriesRef, lset l switch { case h != nil: - zeroHistogram := &histogram.Histogram{} + zeroHistogram := &histogram.Histogram{ + // The CTZeroSample represents a counter reset by definition. + CounterResetHint: histogram.CounterReset, + } s.Lock() // TODO(krajorama): reorganize Commit() to handle samples in append order @@ -819,7 +822,10 @@ func (a *headAppender) AppendHistogramCTZeroSample(ref storage.SeriesRef, lset l }) a.histogramSeries = append(a.histogramSeries, s) case fh != nil: - zeroFloatHistogram := &histogram.FloatHistogram{} + zeroFloatHistogram := &histogram.FloatHistogram{ + // The CTZeroSample represents a counter reset by definition. + CounterResetHint: histogram.CounterReset, + } s.Lock() // TODO(krajorama): reorganize Commit() to handle samples in append order