Skip to content

Commit f335ae6

Browse files
committed
fix: avoid native path for hybrid/classic histograms
isNative() treated any Histogram with a non-zero ZeroThreshold as native, even when classic buckets were present. In the alertmanager tests the incoming histograms have classic buckets and native histogram fields like `ZeroThreshold` but no spans/deltas, so AddHistogram() routed them to the native path, causing validateCount panic when bucket population != sampleCount.
1 parent 5682373 commit f335ae6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

pkg/util/metrics_helper.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,14 @@ type HistogramData struct {
474474

475475
// A histogram is considered native if it has positive/negative spans or a non-zero zero bucket.
476476
func isNative(histo *dto.Histogram) bool {
477-
return len(histo.GetPositiveSpan()) > 0 ||
477+
native := len(histo.GetPositiveSpan()) > 0 ||
478478
len(histo.GetNegativeSpan()) > 0 ||
479479
histo.GetZeroCount() > 0 ||
480480
histo.GetZeroThreshold() > 0
481+
482+
classic := len(histo.GetBucket()) > 0
483+
484+
return native && !classic
481485
}
482486

483487
func (d *HistogramData) hasNative() bool {

0 commit comments

Comments
 (0)