From 9a8bd8eac6c7abccc06399cd48b689fefa09821a Mon Sep 17 00:00:00 2001 From: Jeanette Tan Date: Mon, 16 Oct 2023 14:02:45 +0800 Subject: [PATCH] Fix possible non-counter warning for empty names and native histograms Signed-off-by: Jeanette Tan --- promql/functions.go | 2 +- util/annotations/annotations.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/promql/functions.go b/promql/functions.go index 027c4495a..ecd6f7c8b 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -88,7 +88,7 @@ func extrapolatedRate(vals []parser.Value, args parser.Expressions, enh *EvalNod return enh.Out, annos.Add(annotations.NewMixedFloatsHistogramsWarning(metricName, args[0].PositionRange())) } - if isCounter && + if isCounter && metricName != "" && len(samples.Floats) > 0 && !strings.HasSuffix(metricName, "_total") && !strings.HasSuffix(metricName, "_sum") && !strings.HasSuffix(metricName, "_count") && diff --git a/util/annotations/annotations.go b/util/annotations/annotations.go index 8bdcc65ba..9cfbb121f 100644 --- a/util/annotations/annotations.go +++ b/util/annotations/annotations.go @@ -156,8 +156,8 @@ func NewMixedClassicNativeHistogramsWarning(metricName string, pos posrange.Posi } } -// NewPossibleNonCounterInfo is used when a counter metric does not have the suffixes -// _total, _sum, _count, or _bucket. +// NewPossibleNonCounterInfo is used when a named counter metric with only float samples does not +// have the suffixes _total, _sum, _count, or _bucket. func NewPossibleNonCounterInfo(metricName string, pos posrange.PositionRange) annoErr { return annoErr{ PositionRange: pos,