Skip to content

Commit 4821f75

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 6b76d76 commit 4821f75

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

engine/engine_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,18 @@ 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/type_and_unit.test", // feature unsupported
94-
}, // TODO(sungjin1212): change to test whole cases
97+
"testdata/limit.test", // limitk, limit_ratio
98+
"testdata/at_modifier.test", // missing counter annotations
99+
},
95100
TBRun: t,
96101
}
97-
98102
promqltest.RunBuiltinTests(st, engine)
99103
}
100104

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")
@@ -154,10 +147,6 @@ func (o *matrixSelector) Next(ctx context.Context) ([]model.StepVector, error) {
154147
}
155148

156149
if o.currentStep > o.maxt {
157-
if o.nonCounterMetric != "" && o.hasFloats {
158-
warnings.AddToContext(annotations.NewPossibleNonCounterInfo(o.nonCounterMetric, posrange.PositionRange{}), ctx)
159-
}
160-
161150
return nil, nil
162151
}
163152
if err := o.loadSeries(ctx); err != nil {
@@ -200,7 +189,6 @@ func (o *matrixSelector) Next(ctx context.Context) ([]model.StepVector, error) {
200189
vectors[currStep].AppendHistogram(o.vectorPool, scanner.signature, h)
201190
} else {
202191
vectors[currStep].AppendSample(o.vectorPool, scanner.signature, f)
203-
o.hasFloats = true
204192
}
205193
}
206194
o.telemetry.IncrementSamplesAtTimestamp(scanner.buffer.SampleCount(), seriesTs)
@@ -252,20 +240,6 @@ func (o *matrixSelector) loadSeries(ctx context.Context) error {
252240
o.seriesBatchSize = numSeries
253241
}
254242
o.vectorPool.SetStepSize(int(o.seriesBatchSize))
255-
256-
// Add a warning if rate or increase is applied on metrics which are not named like counters.
257-
if o.functionName == "rate" || o.functionName == "increase" {
258-
if len(series) > 0 {
259-
metricName := series[0].Labels().Get(labels.MetricName)
260-
if metricName != "" &&
261-
!strings.HasSuffix(metricName, "_total") &&
262-
!strings.HasSuffix(metricName, "_sum") &&
263-
!strings.HasSuffix(metricName, "_count") &&
264-
!strings.HasSuffix(metricName, "_bucket") {
265-
o.nonCounterMetric = metricName
266-
}
267-
}
268-
}
269243
})
270244
return err
271245
}

0 commit comments

Comments
 (0)