Fix possible non-counter warning for empty names and native histograms

Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
This commit is contained in:
Jeanette Tan 2023-10-16 14:02:45 +08:00
parent 8a0c9aec1c
commit 9a8bd8eac6
2 changed files with 3 additions and 3 deletions

View File

@ -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())) 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, "_total") &&
!strings.HasSuffix(metricName, "_sum") && !strings.HasSuffix(metricName, "_sum") &&
!strings.HasSuffix(metricName, "_count") && !strings.HasSuffix(metricName, "_count") &&

View File

@ -156,8 +156,8 @@ func NewMixedClassicNativeHistogramsWarning(metricName string, pos posrange.Posi
} }
} }
// NewPossibleNonCounterInfo is used when a counter metric does not have the suffixes // NewPossibleNonCounterInfo is used when a named counter metric with only float samples does not
// _total, _sum, _count, or _bucket. // have the suffixes _total, _sum, _count, or _bucket.
func NewPossibleNonCounterInfo(metricName string, pos posrange.PositionRange) annoErr { func NewPossibleNonCounterInfo(metricName string, pos posrange.PositionRange) annoErr {
return annoErr{ return annoErr{
PositionRange: pos, PositionRange: pos,