mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge pull request #15250 from yeya24/fix-round-delay-name-removal
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Fix round function not hornoring delayed name removal flag
This commit is contained in:
commit
a6fd22b9d2
|
@ -3501,3 +3501,65 @@ histogram {{sum:4 count:4 buckets:[2 2]}} {{sum:6 count:6 buckets:[3 3]}} {{sum:
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEvaluationWithDelayedNameRemovalDisabled(t *testing.T) {
|
||||||
|
opts := promql.EngineOpts{
|
||||||
|
Logger: nil,
|
||||||
|
Reg: nil,
|
||||||
|
EnableAtModifier: true,
|
||||||
|
MaxSamples: 10000,
|
||||||
|
Timeout: 10 * time.Second,
|
||||||
|
EnableDelayedNameRemoval: false,
|
||||||
|
}
|
||||||
|
engine := promqltest.NewTestEngineWithOpts(t, opts)
|
||||||
|
|
||||||
|
promqltest.RunTest(t, `
|
||||||
|
load 5m
|
||||||
|
metric{env="1"} 0 60 120
|
||||||
|
another_metric{env="1"} 60 120 180
|
||||||
|
|
||||||
|
# Does not drop __name__ for vector selector
|
||||||
|
eval instant at 15m metric{env="1"}
|
||||||
|
metric{env="1"} 120
|
||||||
|
|
||||||
|
# Drops __name__ for unary operators
|
||||||
|
eval instant at 15m -metric
|
||||||
|
{env="1"} -120
|
||||||
|
|
||||||
|
# Drops __name__ for binary operators
|
||||||
|
eval instant at 15m metric + another_metric
|
||||||
|
{env="1"} 300
|
||||||
|
|
||||||
|
# Does not drop __name__ for binary comparison operators
|
||||||
|
eval instant at 15m metric <= another_metric
|
||||||
|
metric{env="1"} 120
|
||||||
|
|
||||||
|
# Drops __name__ for binary comparison operators with "bool" modifier
|
||||||
|
eval instant at 15m metric <= bool another_metric
|
||||||
|
{env="1"} 1
|
||||||
|
|
||||||
|
# Drops __name__ for vector-scalar operations
|
||||||
|
eval instant at 15m metric * 2
|
||||||
|
{env="1"} 240
|
||||||
|
|
||||||
|
# Drops __name__ for instant-vector functions
|
||||||
|
eval instant at 15m clamp(metric, 0, 100)
|
||||||
|
{env="1"} 100
|
||||||
|
|
||||||
|
# Drops __name__ for round function
|
||||||
|
eval instant at 15m round(metric)
|
||||||
|
{env="1"} 120
|
||||||
|
|
||||||
|
# Drops __name__ for range-vector functions
|
||||||
|
eval instant at 15m rate(metric{env="1"}[10m])
|
||||||
|
{env="1"} 0.2
|
||||||
|
|
||||||
|
# Does not drop __name__ for last_over_time function
|
||||||
|
eval instant at 15m last_over_time(metric{env="1"}[10m])
|
||||||
|
metric{env="1"} 120
|
||||||
|
|
||||||
|
# Drops name for other _over_time functions
|
||||||
|
eval instant at 15m max_over_time(metric{env="1"}[10m])
|
||||||
|
{env="1"} 120
|
||||||
|
`, engine)
|
||||||
|
}
|
||||||
|
|
|
@ -534,6 +534,9 @@ func funcRound(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper
|
||||||
|
|
||||||
for _, el := range vec {
|
for _, el := range vec {
|
||||||
f := math.Floor(el.F*toNearestInverse+0.5) / toNearestInverse
|
f := math.Floor(el.F*toNearestInverse+0.5) / toNearestInverse
|
||||||
|
if !enh.enableDelayedNameRemoval {
|
||||||
|
el.Metric = el.Metric.DropMetricName()
|
||||||
|
}
|
||||||
enh.Out = append(enh.Out, Sample{
|
enh.Out = append(enh.Out, Sample{
|
||||||
Metric: el.Metric,
|
Metric: el.Metric,
|
||||||
F: f,
|
F: f,
|
||||||
|
|
|
@ -31,6 +31,10 @@ eval instant at 15m metric * 2
|
||||||
eval instant at 15m clamp(metric, 0, 100)
|
eval instant at 15m clamp(metric, 0, 100)
|
||||||
{env="1"} 100
|
{env="1"} 100
|
||||||
|
|
||||||
|
# Drops __name__ for round function
|
||||||
|
eval instant at 15m round(metric)
|
||||||
|
{env="1"} 120
|
||||||
|
|
||||||
# Drops __name__ for range-vector functions
|
# Drops __name__ for range-vector functions
|
||||||
eval instant at 15m rate(metric{env="1"}[10m])
|
eval instant at 15m rate(metric{env="1"}[10m])
|
||||||
{env="1"} 0.2
|
{env="1"} 0.2
|
||||||
|
|
Loading…
Reference in a new issue