Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ require (
github.com/golang/snappy v0.0.4
github.com/gorilla/mux v1.8.0
github.com/grafana/dskit v0.0.0-20211011144203-3a88ec0b675f
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/hashicorp/go-hclog v0.12.2 // indirect
github.com/hashicorp/go-immutable-radix v1.2.0 // indirect
github.com/hashicorp/golang-lru v0.5.4
Expand Down
4 changes: 2 additions & 2 deletions pkg/alertmanager/alertmanager_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/grafana/dskit/crypto/tls"
"github.com/grafana/dskit/grpcclient"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
Expand All @@ -18,8 +20,6 @@ import (

"github.com/grafana/mimir/pkg/alertmanager/alertmanagerpb"
"github.com/grafana/mimir/pkg/ring/client"
"github.com/grafana/mimir/pkg/util/grpcclient"
"github.com/grafana/mimir/pkg/util/tls"
)

// ClientsPool is the interface used to get the client from the pool for a specified address.
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunk/gcp/bigtable_index_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (

"cloud.google.com/go/bigtable"
"github.com/go-kit/kit/log"
"github.com/grafana/dskit/grpcclient"
ot "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"

"github.com/grafana/mimir/pkg/chunk"
chunk_util "github.com/grafana/mimir/pkg/chunk/util"
"github.com/grafana/mimir/pkg/util/grpcclient"
"github.com/grafana/mimir/pkg/util/math"
"github.com/grafana/mimir/pkg/util/spanlogger"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/distributor/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sort"
"time"

"github.com/grafana/dskit/grpcutil"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
Expand All @@ -23,7 +24,6 @@ import (
"github.com/grafana/mimir/pkg/tenant"
"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/extract"
grpc_util "github.com/grafana/mimir/pkg/util/grpc"
"github.com/grafana/mimir/pkg/util/limiter"
"github.com/grafana/mimir/pkg/util/validation"
)
Expand Down Expand Up @@ -240,7 +240,7 @@ func (d *Distributor) queryIngesterStream(ctx context.Context, replicationSet ri
break
} else if err != nil {
// Do not track a failure if the context was canceled.
if !grpc_util.IsGRPCContextCanceled(err) {
if !grpcutil.IsGRPCContextCanceled(err) {
d.ingesterQueryFailures.WithLabelValues(ing.Addr).Inc()
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/frontend/v1/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/grafana/mimir/pkg/scheduler/queue"
"github.com/grafana/mimir/pkg/tenant"
"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/grpcutil"
"github.com/grafana/mimir/pkg/util/httpgrpcutil"
"github.com/grafana/mimir/pkg/util/validation"
)

Expand Down Expand Up @@ -159,7 +159,7 @@ func (f *Frontend) RoundTripGRPC(ctx context.Context, req *httpgrpc.HTTPRequest)
// Propagate trace context in gRPC too - this will be ignored if using HTTP.
tracer, span := opentracing.GlobalTracer(), opentracing.SpanFromContext(ctx)
if tracer != nil && span != nil {
carrier := (*grpcutil.HttpgrpcHeadersCarrier)(req)
carrier := (*httpgrpcutil.HttpgrpcHeadersCarrier)(req)
err := tracer.Inject(span.Context(), opentracing.HTTPHeaders, carrier)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions pkg/frontend/v2/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/services"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
Expand All @@ -28,8 +29,7 @@ import (
"github.com/grafana/mimir/pkg/frontend/v2/frontendv2pb"
"github.com/grafana/mimir/pkg/querier/stats"
"github.com/grafana/mimir/pkg/tenant"
"github.com/grafana/mimir/pkg/util/grpcclient"
"github.com/grafana/mimir/pkg/util/grpcutil"
"github.com/grafana/mimir/pkg/util/httpgrpcutil"
)

// Config for a Frontend.
Expand Down Expand Up @@ -167,7 +167,7 @@ func (f *Frontend) RoundTripGRPC(ctx context.Context, req *httpgrpc.HTTPRequest)
// Propagate trace context in gRPC too - this will be ignored if using HTTP.
tracer, span := opentracing.GlobalTracer(), opentracing.SpanFromContext(ctx)
if tracer != nil && span != nil {
carrier := (*grpcutil.HttpgrpcHeadersCarrier)(req)
carrier := (*httpgrpcutil.HttpgrpcHeadersCarrier)(req)
if err := tracer.Inject(span.Context(), opentracing.HTTPHeaders, carrier); err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/ingester/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (
"flag"

"github.com/go-kit/kit/log"
"github.com/grafana/dskit/grpcclient"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"google.golang.org/grpc"
"google.golang.org/grpc/health/grpc_health_v1"

"github.com/grafana/mimir/pkg/util/grpcclient"
)

var ingesterClientRequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
Expand Down
5 changes: 2 additions & 3 deletions pkg/ingester/client/mimir_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import (
"testing"
"time"

"github.com/grafana/dskit/grpcutil"
"github.com/grafana/dskit/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"

grpc_util "github.com/grafana/mimir/pkg/util/grpc"
)

func TestSendQueryStream(t *testing.T) {
Expand Down Expand Up @@ -76,7 +75,7 @@ func TestSendQueryStream(t *testing.T) {
// Try to receive the response and assert the error we get is the context.Canceled
// wrapped within a gRPC error.
_, err = stream.Recv()
assert.Equal(t, true, grpc_util.IsGRPCContextCanceled(err))
assert.Equal(t, true, grpcutil.IsGRPCContextCanceled(err))

// Wait until the assertions in the server mock have completed.
wg.Wait()
Expand Down
4 changes: 2 additions & 2 deletions pkg/mimir/mimir.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/grpcutil"
"github.com/grafana/dskit/kv/memberlist"
"github.com/grafana/dskit/modules"
"github.com/grafana/dskit/runtimeconfig"
Expand Down Expand Up @@ -60,7 +61,6 @@ import (
"github.com/grafana/mimir/pkg/tenant"
"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/fakeauth"
"github.com/grafana/mimir/pkg/util/grpc/healthcheck"
util_log "github.com/grafana/mimir/pkg/util/log"
"github.com/grafana/mimir/pkg/util/process"
"github.com/grafana/mimir/pkg/util/validation"
Expand Down Expand Up @@ -428,7 +428,7 @@ func (t *Mimir) Run() error {
// before starting servers, register /ready handler and gRPC health check service.
// It should reflect entire Mimir.
t.Server.HTTP.Path("/ready").Handler(t.readyHandler(sm))
grpc_health_v1.RegisterHealthServer(t.Server.GRPC, healthcheck.New(sm))
grpc_health_v1.RegisterHealthServer(t.Server.GRPC, grpcutil.NewHealthCheck(sm))

// Let's listen for events from this manager, and log them.
healthy := func() { level.Info(util_log.Logger).Log("msg", "Application started") }
Expand Down
4 changes: 2 additions & 2 deletions pkg/querier/store_gateway_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/grafana/dskit/crypto/tls"
"github.com/grafana/dskit/grpcclient"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
Expand All @@ -18,8 +20,6 @@ import (

"github.com/grafana/mimir/pkg/ring/client"
"github.com/grafana/mimir/pkg/storegateway/storegatewaypb"
"github.com/grafana/mimir/pkg/util/grpcclient"
"github.com/grafana/mimir/pkg/util/tls"
)

func newStoreGatewayClientFactory(clientCfg grpcclient.Config, reg prometheus.Registerer) client.PoolFactory {
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/store_gateway_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/grpcclient"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/assert"
Expand All @@ -20,7 +21,6 @@ import (
"google.golang.org/grpc"

"github.com/grafana/mimir/pkg/storegateway/storegatewaypb"
"github.com/grafana/mimir/pkg/util/grpcclient"
)

func Test_newStoreGatewayClientFactory(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/querier/worker/scheduler_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/grpcclient"
dsmiddleware "github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/services"
otgrpc "github.com/opentracing-contrib/go-grpc"
Expand All @@ -30,8 +31,7 @@ import (
querier_stats "github.com/grafana/mimir/pkg/querier/stats"
"github.com/grafana/mimir/pkg/ring/client"
"github.com/grafana/mimir/pkg/scheduler/schedulerpb"
"github.com/grafana/mimir/pkg/util/grpcclient"
"github.com/grafana/mimir/pkg/util/grpcutil"
"github.com/grafana/mimir/pkg/util/httpgrpcutil"
util_log "github.com/grafana/mimir/pkg/util/log"
)

Expand Down Expand Up @@ -137,7 +137,7 @@ func (sp *schedulerProcessor) querierLoop(c schedulerpb.SchedulerForQuerier_Quer

tracer := opentracing.GlobalTracer()
// Ignore errors here. If we cannot get parent span, we just don't create new one.
parentSpanContext, _ := grpcutil.GetParentSpanForRequest(tracer, request.HttpRequest)
parentSpanContext, _ := httpgrpcutil.GetParentSpanForRequest(tracer, request.HttpRequest)
if parentSpanContext != nil {
queueSpan, spanCtx := opentracing.StartSpanFromContextWithTracer(ctx, tracer, "querier_processor_runRequest", opentracing.ChildOf(parentSpanContext))
defer queueSpan.Finish()
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/services"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/weaveworks/common/httpgrpc"
"google.golang.org/grpc"

"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/grpcclient"
)

type Config struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruler/client_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
"github.com/grafana/dskit/services"

"github.com/go-kit/kit/log"
"github.com/grafana/dskit/grpcclient"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"google.golang.org/grpc"
"google.golang.org/grpc/health/grpc_health_v1"

"github.com/grafana/mimir/pkg/ring/client"
"github.com/grafana/mimir/pkg/util/grpcclient"
)

// ClientsPool is the interface used to get the client from the pool for a specified address.
Expand Down
3 changes: 1 addition & 2 deletions pkg/ruler/client_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import (
"testing"

"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/grpcclient"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"
"google.golang.org/grpc"

"github.com/grafana/mimir/pkg/util/grpcclient"
)

func Test_newRulerClientFactory(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruler/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

gklog "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/crypto/tls"
config_util "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
Expand All @@ -24,7 +25,6 @@ import (
"github.com/prometheus/prometheus/notifier"

"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/tls"
)

type NotifierConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruler/ruler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/concurrency"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/services"
"github.com/pkg/errors"
Expand All @@ -39,7 +40,6 @@ import (
"github.com/grafana/mimir/pkg/ruler/rulestore"
"github.com/grafana/mimir/pkg/tenant"
"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/grpcclient"
util_log "github.com/grafana/mimir/pkg/util/log"
"github.com/grafana/mimir/pkg/util/validation"
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/services"
otgrpc "github.com/opentracing-contrib/go-grpc"
"github.com/opentracing/opentracing-go"
Expand All @@ -31,8 +32,7 @@ import (
"github.com/grafana/mimir/pkg/scheduler/schedulerpb"
"github.com/grafana/mimir/pkg/tenant"
"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/grpcclient"
"github.com/grafana/mimir/pkg/util/grpcutil"
"github.com/grafana/mimir/pkg/util/httpgrpcutil"
"github.com/grafana/mimir/pkg/util/validation"
)

Expand Down Expand Up @@ -282,7 +282,7 @@ func (s *Scheduler) enqueueRequest(frontendContext context.Context, frontendAddr
// Extract tracing information from headers in HTTP request. FrontendContext doesn't have the correct tracing
// information, since that is a long-running request.
tracer := opentracing.GlobalTracer()
parentSpanContext, err := grpcutil.GetParentSpanForRequest(tracer, msg.HttpRequest)
parentSpanContext, err := httpgrpcutil.GetParentSpanForRequest(tracer, msg.HttpRequest)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/grafana/mimir/pkg/frontend/v2/frontendv2pb"
"github.com/grafana/mimir/pkg/scheduler/schedulerpb"
chunk "github.com/grafana/mimir/pkg/util/grpcutil"
"github.com/grafana/mimir/pkg/util/httpgrpcutil"
)

const testMaxOutstandingPerTenant = 5
Expand Down Expand Up @@ -252,7 +252,7 @@ func TestTracingContext(t *testing.T) {
}

sp, _ := opentracing.StartSpanFromContext(context.Background(), "client")
opentracing.GlobalTracer().Inject(sp.Context(), opentracing.HTTPHeaders, (*chunk.HttpgrpcHeadersCarrier)(req.HttpRequest))
opentracing.GlobalTracer().Inject(sp.Context(), opentracing.HTTPHeaders, (*httpgrpcutil.HttpgrpcHeadersCarrier)(req.HttpRequest))

frontendToScheduler(t, frontendLoop, req)

Expand Down
Loading