Skip to content

Commit

Permalink
Restore more efficient version of NewPossibleNonCounterInfo annotation (
Browse files Browse the repository at this point in the history
prometheus#13022)

Restore more efficient version of NewPossibleNonCounterInfo annotation

Signed-off-by: Jeanette Tan <[email protected]>

---------

Signed-off-by: Jeanette Tan <[email protected]>
  • Loading branch information
zenador authored Jan 16, 2024
1 parent b695e06 commit 72a8f10
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions promql/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"runtime"
"sort"
"strconv"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -1543,6 +1544,18 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, annotations.Annotatio
}
}
ev.samplesStats.UpdatePeak(ev.currentSamples)

if e.Func.Name == "rate" || e.Func.Name == "increase" {
samples := inMatrix[0]
metricName := samples.Metric.Get(labels.MetricName)
if metricName != "" && len(samples.Floats) > 0 &&
!strings.HasSuffix(metricName, "_total") &&
!strings.HasSuffix(metricName, "_sum") &&
!strings.HasSuffix(metricName, "_count") &&
!strings.HasSuffix(metricName, "_bucket") {
warnings.Add(annotations.NewPossibleNonCounterInfo(metricName, e.Args[0].PositionRange()))
}
}
}
ev.samplesStats.UpdatePeak(ev.currentSamples)

Expand Down

0 comments on commit 72a8f10

Please sign in to comment.