mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-13 17:14:05 -08:00
Merge pull request #15327 from prometheus/merge-2.55-into-main2
Merge 2.55 into main
This commit is contained in:
commit
a7793b1010
|
@ -63,6 +63,10 @@ As is traditional with a beta release, we do **not** recommend users install 3.0
|
|||
* [FEATURE] Support config reload automatically - feature flag `auto-reload-config`. #14769
|
||||
* [BUGFIX] Scrape: Do not override target parameter labels with config params. #11029
|
||||
|
||||
## 2.55.1 / 2024-01-04
|
||||
|
||||
* [BUGFIX] `round()` function did not remove `__name__` label. #15250
|
||||
|
||||
## 2.55.0 / 2024-10-22
|
||||
|
||||
* [FEATURE] PromQL: Add experimental `info` function. #14495
|
||||
|
|
|
@ -3928,3 +3928,65 @@ func (s mockSeries) Iterator(it chunkenc.Iterator) chunkenc.Iterator {
|
|||
}
|
||||
return storage.ChainSampleIteratorFromIterators(it, iterables)
|
||||
}
|
||||
|
||||
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 10m metric{env="1"}
|
||||
metric{env="1"} 120
|
||||
|
||||
# Drops __name__ for unary operators
|
||||
eval instant at 10m -metric
|
||||
{env="1"} -120
|
||||
|
||||
# Drops __name__ for binary operators
|
||||
eval instant at 10m metric + another_metric
|
||||
{env="1"} 300
|
||||
|
||||
# Does not drop __name__ for binary comparison operators
|
||||
eval instant at 10m metric <= another_metric
|
||||
metric{env="1"} 120
|
||||
|
||||
# Drops __name__ for binary comparison operators with "bool" modifier
|
||||
eval instant at 10m metric <= bool another_metric
|
||||
{env="1"} 1
|
||||
|
||||
# Drops __name__ for vector-scalar operations
|
||||
eval instant at 10m metric * 2
|
||||
{env="1"} 240
|
||||
|
||||
# Drops __name__ for instant-vector functions
|
||||
eval instant at 10m clamp(metric, 0, 100)
|
||||
{env="1"} 100
|
||||
|
||||
# Drops __name__ for round function
|
||||
eval instant at 10m round(metric)
|
||||
{env="1"} 120
|
||||
|
||||
# Drops __name__ for range-vector functions
|
||||
eval instant at 10m rate(metric{env="1"}[10m])
|
||||
{env="1"} 0.2
|
||||
|
||||
# Does not drop __name__ for last_over_time function
|
||||
eval instant at 10m last_over_time(metric{env="1"}[10m])
|
||||
metric{env="1"} 120
|
||||
|
||||
# Drops name for other _over_time functions
|
||||
eval instant at 10m max_over_time(metric{env="1"}[10m])
|
||||
{env="1"} 120
|
||||
`, engine)
|
||||
}
|
||||
|
|
|
@ -538,6 +538,9 @@ func funcRound(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper
|
|||
continue
|
||||
}
|
||||
f := math.Floor(el.F*toNearestInverse+0.5) / toNearestInverse
|
||||
if !enh.enableDelayedNameRemoval {
|
||||
el.Metric = el.Metric.DropMetricName()
|
||||
}
|
||||
enh.Out = append(enh.Out, Sample{
|
||||
Metric: el.Metric,
|
||||
F: f,
|
||||
|
|
|
@ -31,6 +31,10 @@ eval instant at 10m metric * 2
|
|||
eval instant at 10m clamp(metric, 0, 100)
|
||||
{env="1"} 100
|
||||
|
||||
# Drops __name__ for round function
|
||||
eval instant at 10m round(metric)
|
||||
{env="1"} 120
|
||||
|
||||
# Drops __name__ for range-vector functions
|
||||
eval instant at 10m rate(metric{env="1"}[10m])
|
||||
{env="1"} 0.2
|
||||
|
|
Loading…
Reference in a new issue