Skip to content

Commit

Permalink
fix breaking changes
Browse files Browse the repository at this point in the history
Signed-off-by: alanprot <alanprot@gmail.com>
  • Loading branch information
alanprot committed Apr 2, 2024
1 parent fa03197 commit 1725f90
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 24 deletions.
3 changes: 2 additions & 1 deletion cmd/cortex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
collectorversion "github.com/prometheus/client_golang/prometheus/collectors/version"
"github.com/prometheus/common/version"
"gopkg.in/yaml.v2"

Expand Down Expand Up @@ -46,7 +47,7 @@ func init() {
version.Version = Version
version.Branch = Branch
version.Revision = Revision
prometheus.MustRegister(version.NewCollector("cortex"))
prometheus.MustRegister(collectorversion.NewCollector("cortex"))
prometheus.MustRegister(configHash)
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/alertmanager/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/md5"
"encoding/binary"
"fmt"
"github.com/prometheus/alertmanager/featurecontrol"

"net/http"
"net/url"
"path"
Expand All @@ -22,6 +22,7 @@ import (
"github.com/prometheus/alertmanager/cluster/clusterpb"
"github.com/prometheus/alertmanager/config"
"github.com/prometheus/alertmanager/dispatch"
"github.com/prometheus/alertmanager/featurecontrol"
"github.com/prometheus/alertmanager/inhibit"
"github.com/prometheus/alertmanager/nflog"
"github.com/prometheus/alertmanager/notify"
Expand Down
3 changes: 2 additions & 1 deletion pkg/alertmanager/multitenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"flag"
"fmt"
"github.com/prometheus/alertmanager/featurecontrol"

"net/http"
"net/url"
"os"
Expand All @@ -19,6 +19,7 @@ import (
"github.com/prometheus/alertmanager/cluster"
"github.com/prometheus/alertmanager/cluster/clusterpb"
amconfig "github.com/prometheus/alertmanager/config"
"github.com/prometheus/alertmanager/featurecontrol"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
tsdb_errors "github.com/prometheus/prometheus/tsdb/errors"
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/prometheus/common/route"
"github.com/prometheus/common/version"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/storage"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/weaveworks/common/instrument"
Expand Down Expand Up @@ -159,7 +160,7 @@ func NewQuerierHandler(
cfg Config,
queryable storage.SampleAndChunkQueryable,
exemplarQueryable storage.ExemplarQueryable,
engine v1.QueryEngine,
engine promql.QueryEngine,
distributor Distributor,
reg prometheus.Registerer,
logger log.Logger,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cortex/cortex.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"flag"
"fmt"
"github.com/prometheus/prometheus/promql"
"net/http"
"os"
"reflect"
Expand All @@ -15,7 +16,6 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
prom_storage "github.com/prometheus/prometheus/storage"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/weaveworks/common/server"
"github.com/weaveworks/common/signals"
"google.golang.org/grpc/health/grpc_health_v1"
Expand Down Expand Up @@ -303,7 +303,7 @@ type Cortex struct {
RuntimeConfig *runtimeconfig.Manager
QuerierQueryable prom_storage.SampleAndChunkQueryable
ExemplarQueryable prom_storage.ExemplarQueryable
QuerierEngine v1.QueryEngine
QuerierEngine promql.QueryEngine
QueryFrontendTripperware tripperware.Tripperware

Ruler *ruler.Ruler
Expand Down
3 changes: 1 addition & 2 deletions pkg/cortex/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/rules"
prom_storage "github.com/prometheus/prometheus/storage"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/thanos-io/objstore"
"github.com/thanos-io/promql-engine/engine"
"github.com/thanos-io/promql-engine/logicalplan"
Expand Down Expand Up @@ -556,7 +555,7 @@ func (t *Cortex) initRuler() (serv services.Service, err error) {
if t.Cfg.ExternalPusher != nil && t.Cfg.ExternalQueryable != nil {
rulerRegisterer := prometheus.WrapRegistererWith(prometheus.Labels{"engine": "ruler"}, prometheus.DefaultRegisterer)

var queryEngine v1.QueryEngine
var queryEngine promql.QueryEngine
opts := promql.EngineOpts{
Logger: util_log.Logger,
Reg: rulerRegisterer,
Expand Down
3 changes: 1 addition & 2 deletions pkg/querier/blocks_store_queryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/tsdb/chunkenc"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1512,7 +1511,7 @@ func TestBlocksStoreQuerier_PromQLExecution(t *testing.T) {
}
for _, thanosEngine := range []bool{false, true} {
t.Run(fmt.Sprintf("thanos engine enabled=%t", thanosEngine), func(t *testing.T) {
var queryEngine v1.QueryEngine
var queryEngine promql.QueryEngine
if thanosEngine {
queryEngine = engine.New(engine.Opts{
EngineOpts: opts,
Expand Down
3 changes: 1 addition & 2 deletions pkg/querier/chunk_store_queryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/stretchr/testify/require"
"github.com/thanos-io/promql-engine/engine"
"github.com/thanos-io/promql-engine/logicalplan"
Expand All @@ -35,7 +34,7 @@ func TestChunkQueryable(t *testing.T) {
for _, encoding := range encodings {
for _, query := range queries {
t.Run(fmt.Sprintf("%s/%s/%s/ thanos engine enabled = %t", testcase.name, encoding.name, query.query, thanosEngine), func(t *testing.T) {
var queryEngine v1.QueryEngine
var queryEngine promql.QueryEngine
if thanosEngine {
queryEngine = engine.New(engine.Opts{
EngineOpts: opts,
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/error_translate_queryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestApiStatusCodes(t *testing.T) {
}
}

func createPrometheusAPI(q storage.SampleAndChunkQueryable, engine v1.QueryEngine) *route.Router {
func createPrometheusAPI(q storage.SampleAndChunkQueryable, engine promql.QueryEngine) *route.Router {
api := v1.NewAPI(
engine,
q,
Expand Down
5 changes: 2 additions & 3 deletions pkg/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/util/annotations"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/thanos-io/promql-engine/engine"
"github.com/thanos-io/promql-engine/logicalplan"
"github.com/thanos-io/thanos/pkg/strutil"
Expand Down Expand Up @@ -162,7 +161,7 @@ func getChunksIteratorFunction(cfg Config) chunkIteratorFunc {
}

// New builds a queryable and promql engine.
func New(cfg Config, limits *validation.Overrides, distributor Distributor, stores []QueryableWithFilter, reg prometheus.Registerer, logger log.Logger) (storage.SampleAndChunkQueryable, storage.ExemplarQueryable, v1.QueryEngine) {
func New(cfg Config, limits *validation.Overrides, distributor Distributor, stores []QueryableWithFilter, reg prometheus.Registerer, logger log.Logger) (storage.SampleAndChunkQueryable, storage.ExemplarQueryable, promql.QueryEngine) {
iteratorFunc := getChunksIteratorFunction(cfg)

distributorQueryable := newDistributorQueryable(distributor, cfg.IngesterMetadataStreaming, iteratorFunc, cfg.QueryIngestersWithin, cfg.QueryStoreForLabels)
Expand Down Expand Up @@ -193,7 +192,7 @@ func New(cfg Config, limits *validation.Overrides, distributor Distributor, stor
})
maxConcurrentMetric.Set(float64(cfg.MaxConcurrent))

var queryEngine v1.QueryEngine
var queryEngine promql.QueryEngine
opts := promql.EngineOpts{
Logger: logger,
Reg: reg,
Expand Down
9 changes: 4 additions & 5 deletions pkg/querier/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/tsdb"
"github.com/prometheus/prometheus/util/annotations"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -253,7 +252,7 @@ func TestShouldSortSeriesIfQueryingMultipleQueryables(t *testing.T) {
MaxSamples: 1e6,
Timeout: 1 * time.Minute,
}
var queryEngine v1.QueryEngine
var queryEngine promql.QueryEngine
if thanosEngine {
queryEngine = engine.New(engine.Opts{
EngineOpts: opts,
Expand Down Expand Up @@ -499,7 +498,7 @@ func TestQuerier(t *testing.T) {
for _, iterators := range []bool{false, true} {
iterators := iterators
t.Run(fmt.Sprintf("%s/%s/iterators=%t", query.query, encoding.name, iterators), func(t *testing.T) {
var queryEngine v1.QueryEngine
var queryEngine promql.QueryEngine
if thanosEngine {
queryEngine = engine.New(engine.Opts{
EngineOpts: opts,
Expand Down Expand Up @@ -648,7 +647,7 @@ func TestNoHistoricalQueryToIngester(t *testing.T) {
for _, c := range testCases {
cfg.QueryIngestersWithin = c.queryIngestersWithin
t.Run(fmt.Sprintf("thanosEngine=%t,queryIngestersWithin=%v, test=%s", thanosEngine, c.queryIngestersWithin, c.name), func(t *testing.T) {
var queryEngine v1.QueryEngine
var queryEngine promql.QueryEngine
if thanosEngine {
queryEngine = engine.New(engine.Opts{
EngineOpts: opts,
Expand Down Expand Up @@ -1223,7 +1222,7 @@ func mockDistibutorFor(t *testing.T, cs mockChunkStore, through model.Time) *Moc
return result
}

func testRangeQuery(t testing.TB, queryable storage.Queryable, queryEngine v1.QueryEngine, end model.Time, q query) *promql.Result {
func testRangeQuery(t testing.TB, queryable storage.Queryable, queryEngine promql.QueryEngine, end model.Time, q query) *promql.Result {
from, through, step := time.Unix(0, 0), end.Time(), q.step
ctx := user.InjectOrgID(context.Background(), "0")
query, err := queryEngine.NewRangeQuery(ctx, queryable, nil, q.query, from, through, step)
Expand Down
5 changes: 2 additions & 3 deletions pkg/ruler/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/rules"
"github.com/prometheus/prometheus/storage"
v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/weaveworks/common/httpgrpc"
"github.com/weaveworks/common/user"

Expand Down Expand Up @@ -158,7 +157,7 @@ type RulesLimits interface {
// EngineQueryFunc returns a new engine query function by passing an altered timestamp.
// Modified from Prometheus rules.EngineQueryFunc
// https://github.com/prometheus/prometheus/blob/v2.39.1/rules/manager.go#L189.
func EngineQueryFunc(engine v1.QueryEngine, q storage.Queryable, overrides RulesLimits, userID string, lookbackDelta time.Duration) rules.QueryFunc {
func EngineQueryFunc(engine promql.QueryEngine, q storage.Queryable, overrides RulesLimits, userID string, lookbackDelta time.Duration) rules.QueryFunc {
return func(ctx context.Context, qs string, t time.Time) (promql.Vector, error) {
// Enforce the max query length.
maxQueryLength := overrides.MaxQueryLength(userID)
Expand Down Expand Up @@ -299,7 +298,7 @@ type RulesManager interface {
// ManagerFactory is a function that creates new RulesManager for given user and notifier.Manager.
type ManagerFactory func(ctx context.Context, userID string, notifier *notifier.Manager, logger log.Logger, reg prometheus.Registerer) RulesManager

func DefaultTenantManagerFactory(cfg Config, p Pusher, q storage.Queryable, engine v1.QueryEngine, overrides RulesLimits, evalMetrics *RuleEvalMetrics, reg prometheus.Registerer) ManagerFactory {
func DefaultTenantManagerFactory(cfg Config, p Pusher, q storage.Queryable, engine promql.QueryEngine, overrides RulesLimits, evalMetrics *RuleEvalMetrics, reg prometheus.Registerer) ManagerFactory {
// Wrap errors returned by Queryable to our wrapper, so that we can distinguish between those errors
// and errors returned by PromQL engine. Errors from Queryable can be either caused by user (limits) or internal errors.
// Errors from PromQL are always "user" errors.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1725f90

Please sign in to comment.