diff --git a/engine/bench_test.go b/engine/bench_test.go index 9d4f8e040..2368f6b70 100644 --- a/engine/bench_test.go +++ b/engine/bench_test.go @@ -26,11 +26,12 @@ func BenchmarkChunkDecoding(b *testing.B) { storage := setupStorage(b, 1000, 3, 720) defer storage.Close() + ctx := context.Background() start := time.Unix(0, 0) end := start.Add(6 * time.Hour) step := time.Second * 30 - querier, err := storage.Querier(context.Background(), start.UnixMilli(), end.UnixMilli()) + querier, err := storage.Querier(start.UnixMilli(), end.UnixMilli()) testutil.Ok(b, err) matcher, err := labels.NewMatcher(labels.MatchEqual, labels.MetricName, "http_requests_total") @@ -41,7 +42,7 @@ func BenchmarkChunkDecoding(b *testing.B) { for c := 0; c < b.N; c++ { numIterations := 0 - ss := querier.Select(false, nil, matcher) + ss := querier.Select(ctx, false, nil, matcher) series := make([]chunkenc.Iterator, 0) for ss.Next() { series = append(series, ss.At().Iterator(nil)) @@ -60,7 +61,7 @@ func BenchmarkChunkDecoding(b *testing.B) { b.ResetTimer() for c := 0; c < b.N; c++ { numIterations := 0 - ss := querier.Select(false, nil, matcher) + ss := querier.Select(ctx, false, nil, matcher) series := make([]chunkenc.Iterator, 0) for ss.Next() { series = append(series, ss.At().Iterator(nil)) diff --git a/engine/distributed_test.go b/engine/distributed_test.go index 11a48c257..e3a58960b 100644 --- a/engine/distributed_test.go +++ b/engine/distributed_test.go @@ -15,6 +15,7 @@ import ( "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/storage" + "github.com/prometheus/prometheus/util/annotations" "github.com/thanos-io/promql-engine/api" "github.com/thanos-io/promql-engine/engine" @@ -289,14 +290,7 @@ func TestDistributedAggregations(t *testing.T) { testutil.Ok(t, err) promResult := promQry.Exec(ctx) - roundValues(promResult) - roundValues(distResult) - - // Instant queries have no guarantees on result ordering. - sortByLabels(promResult) - sortByLabels(distResult) - - testutil.Equals(t, promResult, distResult) + testutil.WithGoCmp(comparer).Equals(t, promResult, distResult) }) } @@ -316,9 +310,7 @@ func TestDistributedAggregations(t *testing.T) { testutil.Ok(t, err) promResult := promQry.Exec(ctx) - roundValues(promResult) - roundValues(distResult) - testutil.Equals(t, promResult, distResult) + testutil.WithGoCmp(comparer).Equals(t, promResult, distResult) }) }) } @@ -334,7 +326,7 @@ func TestDistributedEngineWarnings(t *testing.T) { querier := &storage.MockQueryable{ MockQuerier: &storage.MockQuerier{ SelectMockFunction: func(sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet { - return newWarningsSeriesSet(storage.Warnings{errors.New("test warning")}) + return newWarningsSeriesSet(annotations.New().Add(errors.New("test warning"))) }, }, } diff --git a/engine/engine.go b/engine/engine.go index 93a33137a..bc9039dae 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -547,10 +547,7 @@ type compatibilityQuery struct { func (q *compatibilityQuery) Exec(ctx context.Context) (ret *promql.Result) { ctx = warnings.NewContext(ctx) defer func() { - warns := warnings.FromContext(ctx) - if len(warns) > 0 { - ret.Warnings = warns - } + ret.Warnings = warnings.FromContext(ctx) }() // Handle case with strings early on as this does not need us to process samples. diff --git a/engine/engine_test.go b/engine/engine_test.go index 7d47ddb85..76b20e81b 100644 --- a/engine/engine_test.go +++ b/engine/engine_test.go @@ -34,6 +34,7 @@ import ( "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/chunkenc" "github.com/prometheus/prometheus/tsdb/tsdbutil" + "github.com/prometheus/prometheus/util/annotations" "github.com/prometheus/prometheus/util/stats" "github.com/prometheus/prometheus/util/teststorage" "go.uber.org/goleak" @@ -236,8 +237,7 @@ func TestVectorSelectorWithGaps(t *testing.T) { oldResult := q2.Exec(context.Background()) testutil.Ok(t, oldResult.Err) - testutil.Equals(t, oldResult, newResult) - + testutil.WithGoCmp(comparer).Equals(t, oldResult, newResult) } func TestQueriesAgainstOldEngine(t *testing.T) { @@ -1919,21 +1919,7 @@ func TestQueriesAgainstOldEngine(t *testing.T) { defer q2.Close() oldResult := q2.Exec(ctx) - if oldResult.Err != nil { - testutil.NotOk(t, newResult.Err, "expected error "+oldResult.Err.Error()) - return - } - - testutil.Equals(t, newResult.Warnings, oldResult.Warnings) - testutil.Ok(t, newResult.Err) - if hasNaNs(oldResult) { - t.Log("Applying comparison with NaN equality.") - equalsWithNaNs(t, oldResult, newResult) - } else { - emptyLabelsToNil(oldResult) - emptyLabelsToNil(newResult) - testutil.Equals(t, oldResult, newResult) - } + testutil.WithGoCmp(comparer).Equals(t, newResult, oldResult) }) } }) @@ -1943,37 +1929,6 @@ func TestQueriesAgainstOldEngine(t *testing.T) { } } -func equalsWithNaNs(t *testing.T, oldResult, newResult interface{}) { - if reflect.TypeOf(labels.Labels{}).Kind() == reflect.Struct { - testutil.WithGoCmp(cmpopts.EquateNaNs(), cmp.AllowUnexported(labels.Labels{})).Equals(t, oldResult, newResult) - } else { - testutil.WithGoCmp(cmpopts.EquateNaNs()).Equals(t, oldResult, newResult) - } -} - -func hasNaNs(result *promql.Result) bool { - switch result := result.Value.(type) { - case promql.Matrix: - for _, series := range result { - for _, point := range series.Floats { - if math.IsNaN(point.F) { - return true - } - } - } - case promql.Vector: - for _, sample := range result { - if math.IsNaN(sample.F) { - return true - } - } - case promql.Scalar: - return math.IsNaN(result.V) - } - - return false -} - // mergeWithSampleDedup merges samples from series with the same labels, // removing samples with identical timestamps. func mergeWithSampleDedup(series []*mockSeries) []storage.Series { @@ -2020,7 +1975,7 @@ func TestWarnings(t *testing.T) { querier := &storage.MockQueryable{ MockQuerier: &storage.MockQuerier{ SelectMockFunction: func(sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet { - return newWarningsSeriesSet(storage.Warnings{errors.New("test warning")}) + return newWarningsSeriesSet(annotations.New().Add(errors.New("test warning"))) }, }, } @@ -2034,22 +1989,21 @@ func TestWarnings(t *testing.T) { cases := []struct { name string query string - expectedWarns storage.Warnings + expectedWarns annotations.Annotations }{ { name: "single select call", query: "http_requests_total", - expectedWarns: storage.Warnings{ + expectedWarns: annotations.New().Add( errors.New("test warning"), - }, + ), }, { name: "multiple select calls", query: `sum(http_requests_total) / sum(http_responses_total)`, - expectedWarns: storage.Warnings{ - errors.New("test warning"), + expectedWarns: annotations.New().Add( errors.New("test warning"), - }, + ), }, } @@ -3824,19 +3778,7 @@ func TestInstantQuery(t *testing.T) { oldResult := q2.Exec(ctx) - if tc.sortByLabels { - sortByLabels(oldResult) - sortByLabels(newResult) - } - - if hasNaNs(oldResult) { - t.Log("Applying comparison with NaN equality.") - equalsWithNaNs(t, oldResult, newResult) - } else if oldResult.Err != nil && newResult.Err != nil { - testutil.Equals(t, oldResult.Err.Error(), newResult.Err.Error()) - } else { - testutil.Equals(t, oldResult, newResult) - } + testutil.WithGoCmp(comparer).Equals(t, newResult, oldResult) }) } }) @@ -3910,7 +3852,7 @@ type hintRecordingQuerier struct { func (h *hintRecordingQuerier) Close() error { return nil } -func (h *hintRecordingQuerier) Select(sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet { +func (h *hintRecordingQuerier) Select(_ context.Context, sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet { h.mux.Lock() defer h.mux.Unlock() h.hints = append(h.hints, hints) @@ -4423,7 +4365,7 @@ func (m *mockIterator) Err() error { return nil } type testSeriesSet struct { i int series []storage.Series - warns storage.Warnings + warns annotations.Annotations } func newTestSeriesSet(series ...storage.Series) storage.SeriesSet { @@ -4433,17 +4375,17 @@ func newTestSeriesSet(series ...storage.Series) storage.SeriesSet { } } -func newWarningsSeriesSet(warns storage.Warnings) storage.SeriesSet { +func newWarningsSeriesSet(warns annotations.Annotations) storage.SeriesSet { return &testSeriesSet{ i: -1, warns: warns, } } -func (s *testSeriesSet) Next() bool { s.i++; return s.i < len(s.series) } -func (s *testSeriesSet) At() storage.Series { return s.series[s.i] } -func (s *testSeriesSet) Err() error { return nil } -func (s *testSeriesSet) Warnings() storage.Warnings { return s.warns } +func (s *testSeriesSet) Next() bool { s.i++; return s.i < len(s.series) } +func (s *testSeriesSet) At() storage.Series { return s.series[s.i] } +func (s *testSeriesSet) Err() error { return nil } +func (s *testSeriesSet) Warnings() annotations.Annotations { return s.warns } type slowSeries struct{} @@ -4673,8 +4615,6 @@ func testNativeHistograms(t *testing.T, cases []histogramTestCase, opts promql.E testutil.Ok(t, err) newResult := qry.Exec(ctx) testutil.Ok(t, newResult.Err) - newVector, err := newResult.Vector() - testutil.Ok(t, err) qry, err = promEngine.NewInstantQuery(ctx, storage, nil, tc.query, time.Unix(50, 0)) testutil.Ok(t, err) @@ -4688,43 +4628,28 @@ func testNativeHistograms(t *testing.T, cases []histogramTestCase, opts promql.E testutil.Assert(t, len(promVector) == 0) } - sortByLabels(promResult) - sortByLabels(newResult) - if hasNaNs(promResult) { - t.Log("Applying comparison with NaN equality.") - equalsWithNaNs(t, promVector, newVector) - } else { - testutil.Equals(t, promVector, newVector) - } + testutil.WithGoCmp(comparer).Equals(t, newResult, promResult) }) t.Run("range", func(t *testing.T) { ctx := context.Background() qry, err := thanosEngine.NewRangeQuery(ctx, storage, nil, tc.query, time.Unix(50, 0), time.Unix(600, 0), 30*time.Second) testutil.Ok(t, err) - res := qry.Exec(ctx) - testutil.Ok(t, res.Err) - actual, err := res.Matrix() - testutil.Ok(t, err) + newResult := qry.Exec(ctx) + testutil.Ok(t, newResult.Err) qry, err = promEngine.NewRangeQuery(ctx, storage, nil, tc.query, time.Unix(50, 0), time.Unix(600, 0), 30*time.Second) testutil.Ok(t, err) - res = qry.Exec(ctx) - testutil.Ok(t, res.Err) - expected, err := res.Matrix() + promResult := qry.Exec(ctx) + testutil.Ok(t, promResult.Err) + promMatrix, err := promResult.Matrix() testutil.Ok(t, err) // Make sure we're not getting back empty results. if withMixedTypes && tc.wantEmptyForMixedTypes { - testutil.Assert(t, len(expected) == 0) - } - testutil.Equals(t, len(expected), len(actual)) - if hasNaNs(res) { - t.Log("Applying comparison with NaN equality.") - equalsWithNaNs(t, expected, actual) - } else { - testutil.Equals(t, expected, actual) + testutil.Assert(t, len(promMatrix) == 0) } + testutil.WithGoCmp(comparer).Equals(t, newResult, promResult) }) }) } @@ -4922,3 +4847,116 @@ func emptyLabelsToNil(result *promql.Result) { } } } + +// comparer should be used to compare promql results between engines. +var comparer = cmp.Comparer(func(x, y *promql.Result) bool { + compareFloats := func(l, r float64) bool { + const epsilon = 1e-6 + return cmp.Equal(l, r, cmpopts.EquateNaNs(), cmpopts.EquateApprox(0, epsilon)) + } + compareHistograms := func(l, r *histogram.FloatHistogram) bool { + if l == nil && r == nil { + return true + } + return l.Equals(r) + } + + if x.Err != nil && y.Err != nil { + return cmp.Equal(x.Err.Error(), y.Err.Error()) + } else if x.Err != nil || y.Err != nil { + return false + } + + // TODO: compare annotations once we support the same annotations as promql + //if !cmp.Equal(x.Warnings, y.Warnings) { + // return false + //} + + vx, xvec := x.Value.(promql.Vector) + vy, yvec := y.Value.(promql.Vector) + + if xvec && yvec { + if len(vx) != len(vy) { + return false + } + + sort.Sort(samplesByLabels(vx)) + sort.Sort(samplesByLabels(vy)) + + for i := 0; i < len(vx); i++ { + if !equal(vx[i].Metric, vy[i].Metric) { + return false + } + if vx[i].T != vy[i].T { + return false + } + if !compareFloats(vx[i].F, vy[i].F) { + return false + } + if !compareHistograms(vx[i].H, vy[i].H) { + return false + } + } + return true + } + + mx, xmat := x.Value.(promql.Matrix) + my, ymat := y.Value.(promql.Matrix) + + if xmat && ymat { + if len(mx) != len(my) { + return false + } + // Sort matrix before comparing. + sort.Sort(seriesByLabels(mx)) + sort.Sort(seriesByLabels(my)) + for i := 0; i < len(mx); i++ { + mxs := mx[i] + mys := my[i] + + if !equal(mxs.Metric, mys.Metric) { + return false + } + + xps := mxs.Floats + yps := mys.Floats + + if len(xps) != len(yps) { + return false + } + for j := 0; j < len(xps); j++ { + if xps[j].T != yps[j].T { + return false + } + if !compareFloats(xps[j].F, yps[j].F) { + return false + } + } + xph := mxs.Histograms + yph := mys.Histograms + + if len(xph) != len(yph) { + return false + } + for j := 0; j < len(xph); j++ { + if xph[j].T != yph[j].T { + return false + } + if !compareHistograms(xph[j].H, yph[j].H) { + return false + } + } + } + return true + } + + sx, xscalar := x.Value.(promql.Scalar) + sy, yscalar := y.Value.(promql.Scalar) + if xscalar && yscalar { + if sx.T != sy.T { + return false + } + return compareFloats(sx.V, sy.V) + } + return false +}) diff --git a/engine/enginefuzz_test.go b/engine/enginefuzz_test.go index 7f1ea9e29..719fd4fa4 100644 --- a/engine/enginefuzz_test.go +++ b/engine/enginefuzz_test.go @@ -9,7 +9,6 @@ import ( "math" "math/rand" "reflect" - "sort" "testing" "time" @@ -17,7 +16,6 @@ import ( "github.com/efficientgo/core/errors" "github.com/efficientgo/core/testutil" "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql/parser" @@ -435,100 +433,13 @@ func FuzzDistributedEnginePromQLSmithInstantQuery(f *testing.F) { }) } -var comparer = cmp.Comparer(func(x, y *promql.Result) bool { - compareFloats := func(l, r float64) bool { - const epsilon = 1e-6 - return cmp.Equal(l, r, cmpopts.EquateNaNs(), cmpopts.EquateApprox(0, epsilon)) - } - - if x.Err != nil && y.Err != nil { - return cmp.Equal(x.Err.Error(), y.Err.Error()) - } else if x.Err != nil || y.Err != nil { - return false - } - - vx, xvec := x.Value.(promql.Vector) - vy, yvec := y.Value.(promql.Vector) - - if xvec && yvec { - if len(vx) != len(vy) { - return false - } - // Sort vector before comparing. - sort.Slice(vx, func(i, j int) bool { - return labels.Compare(vx[i].Metric, vx[j].Metric) < 0 - }) - sort.Slice(vy, func(i, j int) bool { - return labels.Compare(vy[i].Metric, vy[j].Metric) < 0 - }) - for i := 0; i < len(vx); i++ { - if !equal(vx[i].Metric, vy[i].Metric) { - return false - } - if vx[i].T != vy[i].T { - return false - } - if !compareFloats(vx[i].F, vy[i].F) { - return false - } - } - return true - } - - mx, xmat := x.Value.(promql.Matrix) - my, ymat := y.Value.(promql.Matrix) - - if xmat && ymat { - if len(mx) != len(my) { - return false - } - // Sort matrix before comparing. - sort.Sort(mx) - sort.Sort(my) - for i := 0; i < len(mx); i++ { - mxs := mx[i] - mys := my[i] - - if !equal(mxs.Metric, mys.Metric) { - return false - } - - xps := mxs.Floats - yps := mys.Floats - - if len(xps) != len(yps) { - return false - } - for j := 0; j < len(xps); j++ { - if xps[j].T != yps[j].T { - return false - } - if !compareFloats(xps[j].F, yps[j].F) { - return false - } - } - } - return true - } - - sx, xscalar := x.Value.(promql.Scalar) - sy, yscalar := y.Value.(promql.Scalar) - if xscalar && yscalar { - if sx.T != sy.T { - return false - } - return compareFloats(sx.V, sy.V) - } - return false -}) - func getSeries(ctx context.Context, q storage.Queryable) ([]labels.Labels, error) { - querier, err := q.Querier(ctx, 0, time.Now().Unix()) + querier, err := q.Querier(0, time.Now().Unix()) if err != nil { return nil, err } res := make([]labels.Labels, 0) - ss := querier.Select(false, &storage.SelectHints{Func: "series"}, labels.MustNewMatcher(labels.MatchEqual, "__name__", "http_requests_total")) + ss := querier.Select(ctx, false, &storage.SelectHints{Func: "series"}, labels.MustNewMatcher(labels.MatchEqual, "__name__", "http_requests_total")) for ss.Next() { lbls := ss.At().Labels() res = append(res, lbls) diff --git a/execution/storage/series_selector.go b/execution/storage/series_selector.go index 433fe6a19..771ef6ee3 100644 --- a/execution/storage/series_selector.go +++ b/execution/storage/series_selector.go @@ -61,13 +61,13 @@ func (o *seriesSelector) GetSeries(ctx context.Context, shard int, numShards int } func (o *seriesSelector) loadSeries(ctx context.Context) error { - querier, err := o.storage.Querier(ctx, o.mint, o.maxt) + querier, err := o.storage.Querier(o.mint, o.maxt) if err != nil { return err } defer querier.Close() - seriesSet := querier.Select(false, &o.hints, o.matchers...) + seriesSet := querier.Select(ctx, false, &o.hints, o.matchers...) i := 0 for seriesSet.Next() { s := seriesSet.At() diff --git a/execution/warnings/context.go b/execution/warnings/context.go index 85482247c..368922075 100644 --- a/execution/warnings/context.go +++ b/execution/warnings/context.go @@ -4,7 +4,7 @@ import ( "context" "sync" - "github.com/prometheus/prometheus/storage" + "github.com/prometheus/prometheus/util/annotations" ) type warningKey string @@ -13,22 +13,20 @@ const key warningKey = "promql-warnings" type warnings struct { mu sync.Mutex - warns storage.Warnings + warns annotations.Annotations } func newWarnings() *warnings { - return &warnings{ - warns: make(storage.Warnings, 0), - } + return &warnings{warns: make(annotations.Annotations)} } -func (w *warnings) add(warns storage.Warnings) { +func (w *warnings) add(warns annotations.Annotations) { w.mu.Lock() defer w.mu.Unlock() - w.warns = append(w.warns, warns...) + w.warns = w.warns.Merge(warns) } -func (w *warnings) get() storage.Warnings { +func (w *warnings) get() annotations.Annotations { w.mu.Lock() defer w.mu.Unlock() return w.warns @@ -38,7 +36,7 @@ func NewContext(ctx context.Context) context.Context { return context.WithValue(ctx, key, newWarnings()) } -func AddToContext(warns storage.Warnings, ctx context.Context) { +func AddToContext(warns annotations.Annotations, ctx context.Context) { if len(warns) == 0 { return } @@ -49,6 +47,6 @@ func AddToContext(warns storage.Warnings, ctx context.Context) { w.add(warns) } -func FromContext(ctx context.Context) storage.Warnings { +func FromContext(ctx context.Context) annotations.Annotations { return ctx.Value(key).(*warnings).get() } diff --git a/go.mod b/go.mod index b9fd7c9df..fad937cd7 100644 --- a/go.mod +++ b/go.mod @@ -10,11 +10,11 @@ require ( github.com/google/go-cmp v0.5.9 github.com/prometheus/client_golang v1.16.0 github.com/prometheus/common v0.44.0 - github.com/prometheus/prometheus v0.47.0 + github.com/prometheus/prometheus v0.47.1-0.20231002142425-1492031ef2e0 github.com/stretchr/testify v1.8.4 github.com/zhangyunhao116/umap v0.0.0-20221211160557-cb7705fafa39 go.uber.org/goleak v1.2.1 - golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 + golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b gonum.org/v1/gonum v0.12.0 ) @@ -67,7 +67,7 @@ require ( github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/alertmanager v0.25.0 // indirect + github.com/prometheus/alertmanager v0.26.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common/sigv4 v0.1.0 // indirect github.com/prometheus/procfs v0.11.1 // indirect diff --git a/go.sum b/go.sum index 0cd887de0..ba5147dab 100644 --- a/go.sum +++ b/go.sum @@ -168,7 +168,7 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -187,7 +187,7 @@ github.com/gophercloud/gophercloud v1.5.0 h1:cDN6XFCLKiiqvYpjQLq9AiM7RDRbIC9450W github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd h1:PpuIBO5P3e9hpqBD0O/HjhShYuM6XE0i/lbE6J94kww= github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd/go.mod h1:M5qHK+eWfAv8VR/265dIuEpL3fNfeC21tXXp9itM24A= -github.com/hashicorp/consul/api v1.22.0 h1:ydEvDooB/A0c/xpsBd8GSt7P2/zYPBui4KrNip0xGjE= +github.com/hashicorp/consul/api v1.25.1 h1:CqrdhYzc8XZuPnhIYZWH45toM0LB9ZeYr/gvpLVI3PE= github.com/hashicorp/cronexpr v1.1.2 h1:wG/ZYIKT+RT3QkOdgYc+xsKWVRgnxJ1OJtjjy84fJ9A= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -289,8 +289,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/alertmanager v0.25.0 h1:vbXKUR6PYRiZPRIKfmXaG+dmCKG52RtPL4Btl8hQGvg= -github.com/prometheus/alertmanager v0.25.0/go.mod h1:MEZ3rFVHqKZsw7IcNS/m4AWZeXThmJhumpiWR4eHU/w= +github.com/prometheus/alertmanager v0.26.0 h1:uOMJWfIwJguc3NaM3appWNbbrh6G/OjvaHMk22aBBYc= +github.com/prometheus/alertmanager v0.26.0/go.mod h1:rVcnARltVjavgVaNnmevxK7kOn7IZavyf0KNgHkbEpU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= @@ -316,8 +316,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= -github.com/prometheus/prometheus v0.47.0 h1:tIJJKZGlmrMVsvIt6rMfB8he7CRHEc8ZxS5ubcZtbkM= -github.com/prometheus/prometheus v0.47.0/go.mod h1:J/bmOSjgH7lFxz2gZhrWEZs2i64vMS+HIuZfmYNhJ/M= +github.com/prometheus/prometheus v0.47.1-0.20231002142425-1492031ef2e0 h1:hwaGXm+Cmz3s6YFBxLaEVORpeoxvEHd6H4anoIhCMVM= +github.com/prometheus/prometheus v0.47.1-0.20231002142425-1492031ef2e0/go.mod h1:UC0TwJiF90m2T3iYPQBKnGu8gv3s55dF/EgpTq8gyvo= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -394,8 +394,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= +golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -539,12 +539,12 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.27.3 h1:yR6oQXXnUEBWEWcvPWS0jQL575KoAboQPfJAuKNrw5Y= -k8s.io/apimachinery v0.27.3 h1:Ubye8oBufD04l9QnNtW05idcOe9Z3GQN8+7PqmuVcUM= -k8s.io/client-go v0.27.3 h1:7dnEGHZEJld3lYwxvLl7WoehK6lAq7GvgjxpA3nv1E8= +k8s.io/api v0.28.1 h1:i+0O8k2NPBCPYaMB+uCkseEbawEt/eFaiRqUx8aB108= +k8s.io/apimachinery v0.28.1 h1:EJD40og3GizBSV3mkIoXQBsws32okPOy+MkRyzh6nPY= +k8s.io/client-go v0.28.1 h1:pRhMzB8HyLfVwpngWKE8hDcXRqifh1ga2Z/PU9SXVK8= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 h1:OmK1d0WrkD3IPfkskvroRykOulHVHf0s0ZIFRjyt+UI= +k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/utils v0.0.0-20230711102312-30195339c3c7 h1:ZgnF1KZsYxWIifwSNZFZgNtWE89WI5yiP5WwlfDoIyc= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk= diff --git a/logicalplan/distribute.go b/logicalplan/distribute.go index b86239470..09a7eed7d 100644 --- a/logicalplan/distribute.go +++ b/logicalplan/distribute.go @@ -13,6 +13,7 @@ import ( "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql/parser" + "github.com/prometheus/prometheus/promql/parser/posrange" "github.com/thanos-io/promql-engine/api" "github.com/thanos-io/promql-engine/query" @@ -87,7 +88,7 @@ func (r RemoteExecution) String() string { func (r RemoteExecution) Pretty(level int) string { return r.String() } -func (r RemoteExecution) PositionRange() parser.PositionRange { return parser.PositionRange{} } +func (r RemoteExecution) PositionRange() posrange.PositionRange { return posrange.PositionRange{} } func (r RemoteExecution) Type() parser.ValueType { return parser.ValueTypeMatrix } @@ -104,7 +105,7 @@ func (r Deduplicate) String() string { func (r Deduplicate) Pretty(level int) string { return r.String() } -func (r Deduplicate) PositionRange() parser.PositionRange { return parser.PositionRange{} } +func (r Deduplicate) PositionRange() posrange.PositionRange { return posrange.PositionRange{} } func (r Deduplicate) Type() parser.ValueType { return parser.ValueTypeMatrix } @@ -116,7 +117,7 @@ func (r Noop) String() string { return "noop" } func (r Noop) Pretty(level int) string { return r.String() } -func (r Noop) PositionRange() parser.PositionRange { return parser.PositionRange{} } +func (r Noop) PositionRange() posrange.PositionRange { return posrange.PositionRange{} } func (r Noop) Type() parser.ValueType { return parser.ValueTypeMatrix } diff --git a/logicalplan/filter.go b/logicalplan/filter.go index 56d0c6cab..76cff1fdf 100644 --- a/logicalplan/filter.go +++ b/logicalplan/filter.go @@ -9,6 +9,7 @@ import ( "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql/parser" + "github.com/prometheus/prometheus/promql/parser/posrange" ) type FilteredSelector struct { @@ -22,7 +23,7 @@ func (f FilteredSelector) String() string { func (f FilteredSelector) Pretty(level int) string { return f.String() } -func (f FilteredSelector) PositionRange() parser.PositionRange { return parser.PositionRange{} } +func (f FilteredSelector) PositionRange() posrange.PositionRange { return posrange.PositionRange{} } func (f FilteredSelector) Type() parser.ValueType { return parser.ValueTypeVector }