mirror of
https://github.com/prometheus/prometheus.git
synced 2024-09-20 07:47:31 -07:00
Merge pull request #13559 from prometheus/beorn7/promql
promql: Fix wrongly scoped range vectors
This commit is contained in:
commit
1efca80956
|
@ -708,7 +708,8 @@ func TestScratchBuilder(t *testing.T) {
|
||||||
|
|
||||||
func TestLabels_Hash(t *testing.T) {
|
func TestLabels_Hash(t *testing.T) {
|
||||||
lbls := FromStrings("foo", "bar", "baz", "qux")
|
lbls := FromStrings("foo", "bar", "baz", "qux")
|
||||||
require.Equal(t, lbls.Hash(), lbls.Hash())
|
hash1, hash2 := lbls.Hash(), lbls.Hash()
|
||||||
|
require.Equal(t, hash1, hash2)
|
||||||
require.NotEqual(t, lbls.Hash(), FromStrings("foo", "bar").Hash(), "different labels match.")
|
require.NotEqual(t, lbls.Hash(), FromStrings("foo", "bar").Hash(), "different labels match.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1494,10 +1494,14 @@ func (ev *evaluator) eval(expr parser.Expr) (parser.Value, annotations.Annotatio
|
||||||
otherInArgs[j][0].F = otherArgs[j][0].Floats[step].F
|
otherInArgs[j][0].F = otherArgs[j][0].Floats[step].F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Evaluate the matrix selector for this series
|
||||||
|
// for this step, but only if this is the 1st
|
||||||
|
// iteration or no @ modifier has been used.
|
||||||
|
if ts == ev.startTimestamp || selVS.Timestamp == nil {
|
||||||
maxt := ts - offset
|
maxt := ts - offset
|
||||||
mint := maxt - selRange
|
mint := maxt - selRange
|
||||||
// Evaluate the matrix selector for this series for this step.
|
|
||||||
floats, histograms = ev.matrixIterSlice(it, mint, maxt, floats, histograms)
|
floats, histograms = ev.matrixIterSlice(it, mint, maxt, floats, histograms)
|
||||||
|
}
|
||||||
if len(floats)+len(histograms) == 0 {
|
if len(floats)+len(histograms) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
8
promql/testdata/functions.test
vendored
8
promql/testdata/functions.test
vendored
|
@ -221,19 +221,19 @@ eval instant at 50m deriv(testcounter_reset_middle[100m])
|
||||||
# intercept at t=0: 6.818181818181818
|
# intercept at t=0: 6.818181818181818
|
||||||
# intercept at t=3000: 38.63636363636364
|
# intercept at t=3000: 38.63636363636364
|
||||||
# intercept at t=3000+3600: 76.81818181818181
|
# intercept at t=3000+3600: 76.81818181818181
|
||||||
eval instant at 50m predict_linear(testcounter_reset_middle[100m], 3600)
|
eval instant at 50m predict_linear(testcounter_reset_middle[50m], 3600)
|
||||||
{} 76.81818181818181
|
{} 76.81818181818181
|
||||||
|
|
||||||
# intercept at t = 3000+3600 = 6600
|
# intercept at t = 3000+3600 = 6600
|
||||||
eval instant at 50m predict_linear(testcounter_reset_middle[100m] @ 3000, 3600)
|
eval instant at 50m predict_linear(testcounter_reset_middle[50m] @ 3000, 3600)
|
||||||
{} 76.81818181818181
|
{} 76.81818181818181
|
||||||
|
|
||||||
# intercept at t = 600+3600 = 4200
|
# intercept at t = 600+3600 = 4200
|
||||||
eval instant at 10m predict_linear(testcounter_reset_middle[100m] @ 3000, 3600)
|
eval instant at 10m predict_linear(testcounter_reset_middle[50m] @ 3000, 3600)
|
||||||
{} 51.36363636363637
|
{} 51.36363636363637
|
||||||
|
|
||||||
# intercept at t = 4200+3600 = 7800
|
# intercept at t = 4200+3600 = 7800
|
||||||
eval instant at 70m predict_linear(testcounter_reset_middle[100m] @ 3000, 3600)
|
eval instant at 70m predict_linear(testcounter_reset_middle[50m] @ 3000, 3600)
|
||||||
{} 89.54545454545455
|
{} 89.54545454545455
|
||||||
|
|
||||||
# With http_requests, there is a sample value exactly at the end of
|
# With http_requests, there is a sample value exactly at the end of
|
||||||
|
|
Loading…
Reference in a new issue