diff --git a/pkg/configs/db/postgres/postgres.go b/pkg/configs/db/postgres/postgres.go index c94fd93115..50523795b4 100644 --- a/pkg/configs/db/postgres/postgres.go +++ b/pkg/configs/db/postgres/postgres.go @@ -16,8 +16,7 @@ import ( "github.com/golang-migrate/migrate/v4" _ "github.com/golang-migrate/migrate/v4/database/postgres" // Import the postgres migrations driver _ "github.com/golang-migrate/migrate/v4/source/file" // Import the postgres migrations driver - "github.com/lib/pq" - _ "github.com/lib/pq" // Import the postgres sql driver + "github.com/lib/pq" // Import the postgres sql driver "github.com/pkg/errors" ) diff --git a/pkg/cortexpb/compat_test.go b/pkg/cortexpb/compat_test.go index 63200d6ae1..fed0870ba7 100644 --- a/pkg/cortexpb/compat_test.go +++ b/pkg/cortexpb/compat_test.go @@ -2,7 +2,6 @@ package cortexpb import ( "encoding/json" - stdlibjson "encoding/json" "math" "testing" "unsafe" @@ -21,7 +20,7 @@ func TestJsoniterMarshalForSample(t *testing.T) { } func TestStdlibJsonMarshalForSample(t *testing.T) { - testMarshalling(t, stdlibjson.Marshal, "json: error calling MarshalJSON for type cortexpb.Sample: test sample") + testMarshalling(t, json.Marshal, "json: error calling MarshalJSON for type cortexpb.Sample: test sample") } func testMarshalling(t *testing.T, marshalFn func(v interface{}) ([]byte, error), expectedError string) { diff --git a/pkg/querier/batch/batch.go b/pkg/querier/batch/batch.go index 022b2bce5b..f988fe46d8 100644 --- a/pkg/querier/batch/batch.go +++ b/pkg/querier/batch/batch.go @@ -3,7 +3,6 @@ package batch import ( "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/chunk/encoding" - promchunk "github.com/cortexproject/cortex/pkg/chunk/encoding" "github.com/cortexproject/cortex/pkg/querier/iterators" "github.com/prometheus/common/model" @@ -48,7 +47,7 @@ type iterator interface { // Batch returns the current batch. Must only be called after Seek or Next // have returned true. - Batch() promchunk.Batch + Batch() encoding.Batch Err() error } @@ -74,7 +73,7 @@ func NewGenericChunkMergeIterator(chunks []GenericChunk) chunkenc.Iterator { // call to Next; on calls to Seek, resets batch size to 1. type iteratorAdapter struct { batchSize int - curr promchunk.Batch + curr encoding.Batch underlying iterator } @@ -130,8 +129,8 @@ func (a *iteratorAdapter) Next() bool { for a.curr.Index >= a.curr.Length && a.underlying.Next(a.batchSize) { a.curr = a.underlying.Batch() a.batchSize = a.batchSize * 2 - if a.batchSize > promchunk.BatchSize { - a.batchSize = promchunk.BatchSize + if a.batchSize > encoding.BatchSize { + a.batchSize = encoding.BatchSize } } return a.curr.Index < a.curr.Length diff --git a/pkg/querier/worker/frontend_processor.go b/pkg/querier/worker/frontend_processor.go index 75483cb651..3bdaa0e9a2 100644 --- a/pkg/querier/worker/frontend_processor.go +++ b/pkg/querier/worker/frontend_processor.go @@ -14,7 +14,6 @@ import ( "google.golang.org/grpc" "github.com/cortexproject/cortex/pkg/frontend/v1/frontendv1pb" - "github.com/cortexproject/cortex/pkg/querier/stats" querier_stats "github.com/cortexproject/cortex/pkg/querier/stats" "github.com/cortexproject/cortex/pkg/util/backoff" util_log "github.com/cortexproject/cortex/pkg/util/log" @@ -101,7 +100,7 @@ func (fp *frontendProcessor) process(c frontendv1pb.Frontend_ProcessClient) erro // and cancel the query. We don't actually handle queries in parallel // here, as we're running in lock step with the server - each Recv is // paired with a Send. - go fp.runRequest(ctx, request.HttpRequest, request.StatsEnabled, func(response *httpgrpc.HTTPResponse, stats *stats.QueryStats) error { + go fp.runRequest(ctx, request.HttpRequest, request.StatsEnabled, func(response *httpgrpc.HTTPResponse, stats *querier_stats.QueryStats) error { return c.Send(&frontendv1pb.ClientToFrontend{ HttpResponse: response, Stats: stats, @@ -120,7 +119,7 @@ func (fp *frontendProcessor) process(c frontendv1pb.Frontend_ProcessClient) erro } } -func (fp *frontendProcessor) runRequest(ctx context.Context, request *httpgrpc.HTTPRequest, statsEnabled bool, sendHTTPResponse func(response *httpgrpc.HTTPResponse, stats *stats.QueryStats) error) { +func (fp *frontendProcessor) runRequest(ctx context.Context, request *httpgrpc.HTTPRequest, statsEnabled bool, sendHTTPResponse func(response *httpgrpc.HTTPResponse, stats *querier_stats.QueryStats) error) { var stats *querier_stats.QueryStats if statsEnabled { stats, ctx = querier_stats.ContextWithEmptyStats(ctx) diff --git a/pkg/ring/lifecycler.go b/pkg/ring/lifecycler.go index 0ec987025a..ae77027279 100644 --- a/pkg/ring/lifecycler.go +++ b/pkg/ring/lifecycler.go @@ -13,7 +13,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/pkg/errors" - perrors "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "go.uber.org/atomic" @@ -419,7 +418,7 @@ func (i *Lifecycler) loop(ctx context.Context) error { // First, see if we exist in the cluster, update our state to match if we do, // and add ourselves (without tokens) if we don't. if err := i.initRing(context.Background()); err != nil { - return perrors.Wrapf(err, "failed to join the ring %s", i.RingName) + return errors.Wrapf(err, "failed to join the ring %s", i.RingName) } // We do various period tasks @@ -464,14 +463,14 @@ func (i *Lifecycler) loop(ctx context.Context) error { // let's observe the ring. By using JOINING state, this ingester will be ignored by LEAVING // ingesters, but we also signal that it is not fully functional yet. if err := i.autoJoin(context.Background(), JOINING); err != nil { - return perrors.Wrapf(err, "failed to pick tokens in the KV store, ring: %s", i.RingName) + return errors.Wrapf(err, "failed to pick tokens in the KV store, ring: %s", i.RingName) } level.Info(i.logger).Log("msg", "observing tokens before going ACTIVE", "ring", i.RingName) observeChan = time.After(i.cfg.ObservePeriod) } else { if err := i.autoJoin(context.Background(), ACTIVE); err != nil { - return perrors.Wrapf(err, "failed to pick tokens in the KV store, ring: %s", i.RingName) + return errors.Wrapf(err, "failed to pick tokens in the KV store, ring: %s", i.RingName) } } } @@ -561,7 +560,7 @@ heartbeatLoop: if i.ShouldUnregisterOnShutdown() { if err := i.unregister(context.Background()); err != nil { - return perrors.Wrapf(err, "failed to unregister from the KV store, ring: %s", i.RingName) + return errors.Wrapf(err, "failed to unregister from the KV store, ring: %s", i.RingName) } level.Info(i.logger).Log("msg", "instance removed from the KV store", "ring", i.RingName) } diff --git a/pkg/util/log/log.go b/pkg/util/log/log.go index a195954457..da16d11b93 100644 --- a/pkg/util/log/log.go +++ b/pkg/util/log/log.go @@ -7,7 +7,6 @@ import ( "os" "github.com/go-kit/log" - kitlog "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" "github.com/weaveworks/common/logging" @@ -27,7 +26,7 @@ var ( // Logger is a shared go-kit logger. // TODO: Change all components to take a non-global logger via their constructors. // Prefer accepting a non-global logger as an argument. - Logger = kitlog.NewNopLogger() + Logger = log.NewNopLogger() logMessages = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "log_messages_total", diff --git a/pkg/util/log/wrappers.go b/pkg/util/log/wrappers.go index 50567f6144..0b7e253c45 100644 --- a/pkg/util/log/wrappers.go +++ b/pkg/util/log/wrappers.go @@ -4,7 +4,6 @@ import ( "context" "github.com/go-kit/log" - kitlog "github.com/go-kit/log" "github.com/weaveworks/common/tracing" "github.com/cortexproject/cortex/pkg/tenant" @@ -12,16 +11,16 @@ import ( // WithUserID returns a Logger that has information about the current user in // its details. -func WithUserID(userID string, l kitlog.Logger) kitlog.Logger { +func WithUserID(userID string, l log.Logger) log.Logger { // See note in WithContext. - return kitlog.With(l, "org_id", userID) + return log.With(l, "org_id", userID) } // WithTraceID returns a Logger that has information about the traceID in // its details. -func WithTraceID(traceID string, l kitlog.Logger) kitlog.Logger { +func WithTraceID(traceID string, l log.Logger) log.Logger { // See note in WithContext. - return kitlog.With(l, "traceID", traceID) + return log.With(l, "traceID", traceID) } // WithContext returns a Logger that has information about the current user in @@ -31,7 +30,7 @@ func WithTraceID(traceID string, l kitlog.Logger) kitlog.Logger { // // log := util.WithContext(ctx) // log.Errorf("Could not chunk chunks: %v", err) -func WithContext(ctx context.Context, l kitlog.Logger) kitlog.Logger { +func WithContext(ctx context.Context, l log.Logger) log.Logger { l = headersFromContext(ctx, l) // Weaveworks uses "orgs" and "orgID" to represent Cortex users, @@ -59,7 +58,7 @@ func WithSourceIPs(sourceIPs string, l log.Logger) log.Logger { func headersFromContext(ctx context.Context, l log.Logger) log.Logger { headerContentsMap := HeaderMapFromContext(ctx) for header, contents := range headerContentsMap { - l = kitlog.With(l, header, contents) + l = log.With(l, header, contents) } return l }