Address comments
CI / Go tests (push) Has been cancelled Details
CI / More Go tests (push) Has been cancelled Details
CI / Go tests with previous Go version (push) Has been cancelled Details
CI / UI tests (push) Has been cancelled Details
CI / Go tests on Windows (push) Has been cancelled Details
CI / Mixins tests (push) Has been cancelled Details
CI / Build Prometheus for common architectures (0) (push) Has been cancelled Details
CI / Build Prometheus for common architectures (1) (push) Has been cancelled Details
CI / Build Prometheus for common architectures (2) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (0) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (1) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (10) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (11) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (2) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (3) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (4) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (5) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (6) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (7) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (8) (push) Has been cancelled Details
CI / Build Prometheus for all architectures (9) (push) Has been cancelled Details
CI / Check generated parser (push) Has been cancelled Details
CI / golangci-lint (push) Has been cancelled Details
CI / fuzzing (push) Has been cancelled Details
CI / codeql (push) Has been cancelled Details
CI / Report status of build Prometheus for all architectures (push) Has been cancelled Details
CI / Publish main branch artifacts (push) Has been cancelled Details
CI / Publish release artefacts (push) Has been cancelled Details
CI / Publish UI on npm Registry (push) Has been cancelled Details

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
This commit is contained in:
Arthur Silva Sens 2025-05-29 15:26:34 -03:00
parent f74b019505
commit 1ef361bc45
No known key found for this signature in database
3 changed files with 7 additions and 7 deletions

View File

@ -1901,8 +1901,8 @@ func (ev *evaluator) eval(ctx context.Context, expr parser.Expr) (parser.Value,
if ev.enableTypeAndUnitLabels { if ev.enableTypeAndUnitLabels {
// When type-and-unit-labels feature is enabled, check __type__ label // When type-and-unit-labels feature is enabled, check __type__ label
typeLabel := inMatrix[0].Metric.Get("__type__") typeLabel := inMatrix[0].Metric.Get("__type__")
if typeLabel != "counter" { if typeLabel != string(model.MetricTypeCounter) {
warnings.Add(annotations.NewPossibleNonCounterLabelInfo(metricName, e.Args[0].PositionRange())) warnings.Add(annotations.NewPossibleNonCounterLabelInfo(metricName, typeLabel, e.Args[0].PositionRange()))
} }
} else if !strings.HasSuffix(metricName, "_total") || } else if !strings.HasSuffix(metricName, "_total") ||
!strings.HasSuffix(metricName, "_sum") || !strings.HasSuffix(metricName, "_sum") ||

View File

@ -3503,7 +3503,7 @@ func TestRateAnnotations(t *testing.T) {
expr: "rate(series[1m1s])", expr: "rate(series[1m1s])",
typeAndUnitLabelsEnabled: true, typeAndUnitLabelsEnabled: true,
expectedInfoAnnotations: []string{ expectedInfoAnnotations: []string{
`PromQL info: metric might not be a counter, __type__ label is not set to "counter": "series" (1:6)`, `PromQL info: metric might not be a counter, __type__ label is not set to "counter", got "": "series" (1:6)`,
}, },
expectedWarningAnnotations: []string{}, expectedWarningAnnotations: []string{},
}, },
@ -3514,7 +3514,7 @@ func TestRateAnnotations(t *testing.T) {
expr: "increase(series[1m1s])", expr: "increase(series[1m1s])",
typeAndUnitLabelsEnabled: true, typeAndUnitLabelsEnabled: true,
expectedInfoAnnotations: []string{ expectedInfoAnnotations: []string{
`PromQL info: metric might not be a counter, __type__ label is not set to "counter": "series" (1:10)`, `PromQL info: metric might not be a counter, __type__ label is not set to "counter", got "": "series" (1:10)`,
}, },
expectedWarningAnnotations: []string{}, expectedWarningAnnotations: []string{},
}, },

View File

@ -147,7 +147,7 @@ var (
IncompatibleBucketLayoutInBinOpWarning = fmt.Errorf("%w: incompatible bucket layout encountered for binary operator", PromQLWarning) IncompatibleBucketLayoutInBinOpWarning = fmt.Errorf("%w: incompatible bucket layout encountered for binary operator", PromQLWarning)
PossibleNonCounterInfo = fmt.Errorf("%w: metric might not be a counter, name does not end in _total/_sum/_count/_bucket:", PromQLInfo) PossibleNonCounterInfo = fmt.Errorf("%w: metric might not be a counter, name does not end in _total/_sum/_count/_bucket:", PromQLInfo)
PossibleNonCounterLabelInfo = fmt.Errorf("%w: metric might not be a counter, __type__ label is not set to %q:", PromQLInfo, "counter") PossibleNonCounterLabelInfo = fmt.Errorf("%w: metric might not be a counter, __type__ label is not set to %q", PromQLInfo, model.MetricTypeCounter)
HistogramQuantileForcedMonotonicityInfo = fmt.Errorf("%w: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) for metric name", PromQLInfo) HistogramQuantileForcedMonotonicityInfo = fmt.Errorf("%w: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) for metric name", PromQLInfo)
IncompatibleTypesInBinOpInfo = fmt.Errorf("%w: incompatible sample types encountered for binary operator", PromQLInfo) IncompatibleTypesInBinOpInfo = fmt.Errorf("%w: incompatible sample types encountered for binary operator", PromQLInfo)
HistogramIgnoredInAggregationInfo = fmt.Errorf("%w: ignored histogram in", PromQLInfo) HistogramIgnoredInAggregationInfo = fmt.Errorf("%w: ignored histogram in", PromQLInfo)
@ -273,10 +273,10 @@ func NewPossibleNonCounterInfo(metricName string, pos posrange.PositionRange) er
// NewPossibleNonCounterLabelInfo is used when a named counter metric with only float samples does not // NewPossibleNonCounterLabelInfo is used when a named counter metric with only float samples does not
// have the __type__ label set to "counter". // have the __type__ label set to "counter".
func NewPossibleNonCounterLabelInfo(metricName string, pos posrange.PositionRange) error { func NewPossibleNonCounterLabelInfo(metricName, typeLabel string, pos posrange.PositionRange) error {
return annoErr{ return annoErr{
PositionRange: pos, PositionRange: pos,
Err: fmt.Errorf("%w %q", PossibleNonCounterLabelInfo, metricName), Err: fmt.Errorf("%w, got %q: %q", PossibleNonCounterLabelInfo, typeLabel, metricName),
} }
} }