Skip to content

Commit

Permalink
Upgrade dskit to remove direct dependency on weaveworks/common (#2207)
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskorn authored Aug 4, 2023
1 parent 142b488 commit 4832d64
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 41 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/grafana/dskit v0.0.0-20230721071918-7ba66579c3ac
github.com/grafana/dskit v0.0.0-20230804003603-740f56bd2934
github.com/grafana/mimir v0.0.0-20230728104016-12792f6adf17
github.com/grafana/pyroscope/api v0.0.0-00010101000000-000000000000
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd
Expand Down Expand Up @@ -55,7 +55,6 @@ require (
github.com/thanos-io/thanos v0.31.0
github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/valyala/bytebufferpool v1.0.0
github.com/weaveworks/common v0.0.0-20230714173453-d1f8877b91ce
github.com/xlab/treeprint v1.2.0
go.uber.org/atomic v1.11.0
go.uber.org/goleak v1.2.1
Expand Down Expand Up @@ -237,6 +236,7 @@ require (
github.com/tencentyun/cos-go-sdk-v5 v0.7.40 // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/vultr/govultr/v2 v2.17.2 // indirect
github.com/weaveworks/common v0.0.0-20230714173453-d1f8877b91ce // indirect
github.com/weaveworks/promrus v1.2.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grafana/dskit v0.0.0-20230721071918-7ba66579c3ac h1:IjWdT7S6I2AlnOR3hmw72mwDDUaE8/Ov1ncftKNe/BQ=
github.com/grafana/dskit v0.0.0-20230721071918-7ba66579c3ac/go.mod h1:M03k2fzuQ2n9TVE1xfVKTESibxsXdw0wYfWT3+9Owp4=
github.com/grafana/dskit v0.0.0-20230804003603-740f56bd2934 h1:W1g+y6rOO7K/Jm2XNPxIXyJisJSJ25uiVVaSa7N1Zwo=
github.com/grafana/dskit v0.0.0-20230804003603-740f56bd2934/go.mod h1:Xg0aN3EpqkYFW1ZxGyIl4BGEpr3QrCQOM1aWalpU3ik=
github.com/grafana/gomemcache v0.0.0-20230316202710-a081dae0aba9 h1:WB3bGH2f1UN6jkd6uAEWfHB8OD7dKJ0v2Oo6SNfhpfQ=
github.com/grafana/gomemcache v0.0.0-20230316202710-a081dae0aba9/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU=
github.com/grafana/memberlist v0.3.1-0.20220708130638-bd88e10a3d91 h1:/NipyHnOmvRsVzj81j2qE0VxsvsqhOB0f4vJIhk2qCQ=
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"github.com/go-kit/log/level"
"github.com/gorilla/mux"
"github.com/grafana/dskit/kv/memberlist"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/server"
grpcgw "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/weaveworks/common/middleware"
"github.com/weaveworks/common/server"

"github.com/grafana/pyroscope/public"

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"testing"

"github.com/go-kit/log"
"github.com/grafana/dskit/server"
grpcgw "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/server"
"google.golang.org/protobuf/encoding/protojson"

"github.com/grafana/pyroscope/pkg/util/gziphandler"
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/services"
"github.com/grafana/dskit/test"
"github.com/grafana/dskit/user"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"
"go.uber.org/atomic"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
Expand Down
4 changes: 2 additions & 2 deletions pkg/phlare/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
"github.com/go-kit/log/level"
"github.com/grafana/dskit/kv/codec"
"github.com/grafana/dskit/kv/memberlist"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/ring"
"github.com/grafana/dskit/runtimeconfig"
"github.com/grafana/dskit/server"
"github.com/grafana/dskit/services"
grpcgw "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/opentracing/opentracing-go"
Expand All @@ -22,8 +24,6 @@ import (
"github.com/prometheus/common/version"
objstoretracing "github.com/thanos-io/objstore/tracing/opentracing"
"github.com/thanos-io/thanos/pkg/discovery/dns"
"github.com/weaveworks/common/middleware"
"github.com/weaveworks/common/server"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"google.golang.org/genproto/googleapis/api/httpbody"
Expand Down
10 changes: 5 additions & 5 deletions pkg/phlare/phlare.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ import (
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/grpcutil"
"github.com/grafana/dskit/kv/memberlist"
dslog "github.com/grafana/dskit/log"
"github.com/grafana/dskit/modules"
"github.com/grafana/dskit/ring"
"github.com/grafana/dskit/runtimeconfig"
"github.com/grafana/dskit/server"
"github.com/grafana/dskit/services"
"github.com/grafana/dskit/signals"
wwtracing "github.com/grafana/dskit/tracing"
grpcgw "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/prometheus/client_golang/prometheus"
commonconfig "github.com/prometheus/common/config"
"github.com/prometheus/common/version"
"github.com/samber/lo"
"github.com/weaveworks/common/logging"
"github.com/weaveworks/common/server"
"github.com/weaveworks/common/signals"
wwtracing "github.com/weaveworks/common/tracing"

"github.com/grafana/pyroscope/api/gen/proto/go/push/v1/pushv1connect"
"github.com/grafana/pyroscope/pkg/agent"
Expand Down Expand Up @@ -482,7 +482,7 @@ func initLogger(cfg *server.Config) log.Logger {
// this works in go 1.12, but doesn't work in versions earlier.
// it will always shows the wrapper function generated by compiler
// marked <autogenerated> in old versions.
cfg.Log = logging.GoKit(log.With(logger, "caller", log.Caller(4)))
cfg.Log = dslog.GoKit(log.With(logger, "caller", log.Caller(4)))
logger = log.With(logger, "ts", log.DefaultTimestampUTC)
util.Logger = logger
return logger
Expand Down
4 changes: 2 additions & 2 deletions pkg/querier/worker/scheduler_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
"github.com/gogo/status"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/ring/client"
"github.com/grafana/dskit/services"
"github.com/grafana/dskit/user"
otgrpc "github.com/opentracing-contrib/go-grpc"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/weaveworks/common/middleware"
"github.com/weaveworks/common/user"
"go.uber.org/atomic"
"google.golang.org/grpc"
"google.golang.org/grpc/health/grpc_health_v1"
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/ring"
"github.com/grafana/dskit/services"
"github.com/grafana/dskit/tenant"
"github.com/grafana/dskit/user"
otgrpc "github.com/opentracing-contrib/go-grpc"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/weaveworks/common/middleware"
"github.com/weaveworks/common/user"
"google.golang.org/grpc"

"github.com/grafana/pyroscope/pkg/frontend/frontendpb"
Expand Down
2 changes: 1 addition & 1 deletion pkg/tenant/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/bufbuild/connect-go"
"github.com/grafana/dskit/tenant"
"github.com/weaveworks/common/user"
"github.com/grafana/dskit/user"
)

// DefaultTenantID is the default tenant ID used when the interceptor is disabled.
Expand Down
2 changes: 1 addition & 1 deletion pkg/tenant/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tenant
import (
"context"

"github.com/weaveworks/common/user"
"github.com/grafana/dskit/user"
)

const ErrNoTenantID = user.ErrNoOrgID
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"net/http"

"github.com/weaveworks/common/httpgrpc"
"github.com/grafana/dskit/httpgrpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"net/http/httptest"
"testing"

"github.com/grafana/dskit/httpgrpc"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/httpgrpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand Down
14 changes: 7 additions & 7 deletions pkg/util/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (

"github.com/felixge/httpsnoop"
"github.com/gorilla/mux"
"github.com/grafana/dskit/instrument"
"github.com/grafana/dskit/log"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/multierror"
"github.com/grafana/dskit/tracing"
"github.com/grafana/dskit/user"
"github.com/opentracing-contrib/go-stdlib/nethttp"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/weaveworks/common/instrument"
"github.com/weaveworks/common/logging"
"github.com/weaveworks/common/middleware"
"github.com/weaveworks/common/tracing"
"github.com/weaveworks/common/user"
"golang.org/x/net/http2"
"gopkg.in/yaml.v3"

Expand Down Expand Up @@ -86,14 +86,14 @@ const (

// Log middleware logs http requests
type Log struct {
Log logging.Interface
Log log.Interface
LogRequestHeaders bool // LogRequestHeaders true -> dump http headers at debug log level
LogRequestAtInfoLevel bool // LogRequestAtInfoLevel true -> log requests at info log level
SourceIPs *middleware.SourceIPExtractor
}

// logWithRequest information from the request and context as fields.
func (l Log) logWithRequest(r *http.Request) logging.Interface {
func (l Log) logWithRequest(r *http.Request) log.Interface {
localLog := l.Log
traceID, ok := tracing.ExtractTraceID(r.Context())
if ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/bufbuild/connect-go"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/weaveworks/common/tracing"
"github.com/grafana/dskit/tracing"

"github.com/grafana/pyroscope/pkg/tenant"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/go-kit/log"
"github.com/grafana/dskit/tenant"
"github.com/weaveworks/common/tracing"
"github.com/grafana/dskit/tracing"
)

// Logger is a global logger to use only where you cannot inject a logger.
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"os"
"runtime"

"github.com/grafana/dskit/httpgrpc"
"github.com/grafana/dskit/middleware"
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/weaveworks/common/httpgrpc"
"github.com/weaveworks/common/middleware"
)

const maxStacksize = 8 * 1024
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strconv"
"time"

"github.com/grafana/dskit/httpgrpc"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/httpgrpc"
)

func TimeToMillis(t time.Time) int64 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/validation/user_limits_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"net/http/httptest"
"testing"

"github.com/grafana/dskit/user"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"
)

func TestTenantLimitsHandler(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions tools/doc-generator/parse/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import (
"time"
"unicode"

"github.com/grafana/regexp"

"github.com/go-kit/log"
"github.com/grafana/dskit/flagext"
dslog "github.com/grafana/dskit/log"
"github.com/grafana/regexp"
"github.com/pkg/errors"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/relabel"
"github.com/weaveworks/common/logging"
)

const (
Expand Down Expand Up @@ -483,7 +482,7 @@ func getFieldExample(fieldKey string, fieldType reflect.Type) *FieldExample {
}

func getCustomFieldEntry(cfg interface{}, field reflect.StructField, fieldValue reflect.Value, flags map[uintptr]*flag.Flag) *ConfigEntry {
if field.Type == reflect.TypeOf(logging.Level{}) || field.Type == reflect.TypeOf(logging.Format{}) {
if field.Type == reflect.TypeOf(dslog.Level{}) || field.Type == reflect.TypeOf(dslog.Format{}) {
fieldFlag := getFieldFlag(field, fieldValue, flags)
if fieldFlag == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion tools/doc-generator/parse/root_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/kv/memberlist"
"github.com/weaveworks/common/server"
"github.com/grafana/dskit/server"

"github.com/grafana/pyroscope/pkg/agent"
"github.com/grafana/pyroscope/pkg/distributor"
Expand Down

0 comments on commit 4832d64

Please sign in to comment.