Skip to content

Commit 339c9cc

Browse files
committed
engine: remove counter suffix annotation
This commit removes the annotation that is added when a metric has a name that is not indicative of a counter. This annotation is mostly spam that the query author cannot act upon. Signed-off-by: Michael Hoffmann <[email protected]>
1 parent 00c0888 commit 339c9cc

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

engine/engine_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ func TestPromqlAcceptance(t *testing.T) {
8787
NoStepSubqueryIntervalFn: func(rangeMillis int64) int64 { return 30 * time.Second.Milliseconds() },
8888
}})
8989

90+
// TODO(mhoffmann): we cannot skip at individual test level yet, only full test files
91+
// it would be great if we could just skip individual tests here for features we dont
92+
// want to support.
9093
st := &skipTest{
9194
skipTests: []string{
9295
"testdata/name_label_dropping.test", // feature unsupported
9396
"testdata/limit.test", // limitk, limit_ratio
94-
}, // TODO(sungjin1212): change to test whole cases
97+
"testdata/at_modifier.test", // missing counter annotations
98+
},
9599
TBRun: t,
96100
}
97101

storage/prometheus/matrix_selector.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import (
77
"context"
88
"fmt"
99
"math"
10-
"strings"
1110
"sync"
1211
"time"
1312

1413
"github.com/thanos-io/promql-engine/execution/model"
1514
"github.com/thanos-io/promql-engine/execution/parse"
1615
"github.com/thanos-io/promql-engine/execution/telemetry"
17-
"github.com/thanos-io/promql-engine/execution/warnings"
1816
"github.com/thanos-io/promql-engine/extlabels"
1917
"github.com/thanos-io/promql-engine/query"
2018
"github.com/thanos-io/promql-engine/ringbuffer"
@@ -23,9 +21,7 @@ import (
2321
"github.com/prometheus/prometheus/model/histogram"
2422
"github.com/prometheus/prometheus/model/labels"
2523
"github.com/prometheus/prometheus/model/value"
26-
"github.com/prometheus/prometheus/promql/parser/posrange"
2724
"github.com/prometheus/prometheus/tsdb/chunkenc"
28-
"github.com/prometheus/prometheus/util/annotations"
2925
)
3026

3127
type matrixScanner struct {
@@ -71,9 +67,6 @@ type matrixSelector struct {
7167

7268
// Lookback delta for extended range functions.
7369
extLookbackDelta int64
74-
75-
nonCounterMetric string
76-
hasFloats bool
7770
}
7871

7972
var ErrNativeHistogramsNotSupported = errors.New("native histograms are not supported in extended range functions")
@@ -160,10 +153,6 @@ func (o *matrixSelector) Next(ctx context.Context) ([]model.StepVector, error) {
160153
}
161154

162155
if o.currentStep > o.maxt {
163-
if o.nonCounterMetric != "" && o.hasFloats {
164-
warnings.AddToContext(annotations.NewPossibleNonCounterInfo(o.nonCounterMetric, posrange.PositionRange{}), ctx)
165-
}
166-
167156
return nil, nil
168157
}
169158
if err := o.loadSeries(ctx); err != nil {
@@ -207,7 +196,6 @@ func (o *matrixSelector) Next(ctx context.Context) ([]model.StepVector, error) {
207196
vectors[currStep].AppendHistogram(o.vectorPool, scanner.signature, h)
208197
} else {
209198
vectors[currStep].AppendSample(o.vectorPool, scanner.signature, f)
210-
o.hasFloats = true
211199
}
212200
}
213201
o.IncrementSamplesAtTimestamp(scanner.buffer.Len(), seriesTs)
@@ -258,20 +246,6 @@ func (o *matrixSelector) loadSeries(ctx context.Context) error {
258246
o.seriesBatchSize = numSeries
259247
}
260248
o.vectorPool.SetStepSize(int(o.seriesBatchSize))
261-
262-
// Add a warning if rate or increase is applied on metrics which are not named like counters.
263-
if o.functionName == "rate" || o.functionName == "increase" {
264-
if len(series) > 0 {
265-
metricName := series[0].Labels().Get(labels.MetricName)
266-
if metricName != "" &&
267-
!strings.HasSuffix(metricName, "_total") &&
268-
!strings.HasSuffix(metricName, "_sum") &&
269-
!strings.HasSuffix(metricName, "_count") &&
270-
!strings.HasSuffix(metricName, "_bucket") {
271-
o.nonCounterMetric = metricName
272-
}
273-
}
274-
}
275249
})
276250
return err
277251
}

0 commit comments

Comments
 (0)