Skip to content

Commit

Permalink
Upgrade dskit to use packages migrated from weaveworks/common
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskorn committed Aug 4, 2023
1 parent 1221658 commit 796ae69
Show file tree
Hide file tree
Showing 245 changed files with 1,248 additions and 691 deletions.
6 changes: 3 additions & 3 deletions clients/cmd/docker-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/docker/go-plugins-helpers/sdk"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
dslog "github.com/grafana/dskit/log"
"github.com/prometheus/common/version"
"github.com/weaveworks/common/logging"

"github.com/grafana/loki/pkg/util"
_ "github.com/grafana/loki/pkg/util/build"
Expand All @@ -19,7 +19,7 @@ import (

const socketAddress = "/run/docker/plugins/loki.sock"

var logLevel logging.Level
var logLevel dslog.Level

func main() {
levelVal := os.Getenv("LOG_LEVEL")
Expand Down Expand Up @@ -51,7 +51,7 @@ func main() {
}
}

func newLogger(lvl logging.Level) log.Logger {
func newLogger(lvl dslog.Level) log.Logger {
// plugin logs must be stdout to appear.
logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stdout))
logger = level.NewFilter(logger, util.LogFilter(lvl.String()))
Expand Down
6 changes: 3 additions & 3 deletions clients/cmd/fluent-bit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"time"

"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/log"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/logging"

"github.com/grafana/loki/clients/pkg/logentry/logql"
"github.com/grafana/loki/clients/pkg/promtail/client"
Expand Down Expand Up @@ -45,7 +45,7 @@ const (
type config struct {
clientConfig client.Config
bufferConfig bufferConfig
logLevel logging.Level
logLevel log.Level
autoKubernetesLabels bool
removeKeys []string
labelKeys []string
Expand Down Expand Up @@ -152,7 +152,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
if logLevel == "" {
logLevel = "info"
}
var level logging.Level
var level log.Level
if err := level.Set(logLevel); err != nil {
return nil, fmt.Errorf("invalid log level: %v", logLevel)
}
Expand Down
6 changes: 3 additions & 3 deletions clients/cmd/fluent-bit/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/log"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/logging"

"github.com/grafana/loki/clients/pkg/promtail/client"

Expand Down Expand Up @@ -210,8 +210,8 @@ func mustParseURL(u string) flagext.URLValue {
return flagext.URLValue{URL: parsed}
}

func mustParseLogLevel(l string) logging.Level {
level := logging.Level{}
func mustParseLogLevel(l string) log.Level {
level := log.Level{}
err := level.Set(l)
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions clients/cmd/fluent-bit/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/go-logfmt/logfmt"
dslog "github.com/grafana/dskit/log"
jsoniter "github.com/json-iterator/go"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/logging"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/client"
Expand Down Expand Up @@ -268,7 +268,7 @@ func (l *loki) createLine(records map[string]interface{}, f format) (string, err
}
}

func newLogger(logLevel logging.Level) log.Logger {
func newLogger(logLevel dslog.Level) log.Logger {
logger := log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
logger = level.NewFilter(logger, util.LogFilter(logLevel.String()))
logger = log.With(logger, "caller", log.Caller(3))
Expand Down
4 changes: 2 additions & 2 deletions clients/cmd/fluent-bit/out_grafana_loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/fluent/fluent-bit-go/output"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
dslog "github.com/grafana/dskit/log"
"github.com/prometheus/common/version"
"github.com/weaveworks/common/logging"

_ "github.com/grafana/loki/pkg/util/build"
)
Expand All @@ -28,7 +28,7 @@ var (
)

func init() {
var logLevel logging.Level
var logLevel dslog.Level
_ = logLevel.Set("info")
logger = newLogger(logLevel)
}
Expand Down
6 changes: 3 additions & 3 deletions clients/cmd/promtail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/log"
"github.com/grafana/dskit/tracing"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"
"github.com/weaveworks/common/logging"
"github.com/weaveworks/common/tracing"

"github.com/grafana/loki/clients/pkg/logentry/stages"
"github.com/grafana/loki/clients/pkg/promtail"
Expand Down Expand Up @@ -102,7 +102,7 @@ func main() {
}

// Init the logger which will honor the log level set in cfg.Server
if reflect.DeepEqual(&config.Config.ServerConfig.Config.LogLevel, &logging.Level{}) {
if reflect.DeepEqual(&config.Config.ServerConfig.Config.LogLevel, &log.Level{}) {
fmt.Println("Invalid log level")
exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/logentry/stages/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"testing"
"time"

ww "github.com/grafana/dskit/server"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"

util_log "github.com/grafana/loki/pkg/util/log"
)
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/logentry/stages/labelallow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"testing"
"time"

ww "github.com/grafana/dskit/server"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"

util_log "github.com/grafana/loki/pkg/util/log"
)
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/logentry/stages/labeldrop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"testing"
"time"

ww "github.com/grafana/dskit/server"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"

util_log "github.com/grafana/loki/pkg/util/log"
)
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/logentry/stages/multiline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"testing"
"time"

ww "github.com/grafana/dskit/server"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/promtail/api"

Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/logentry/stages/pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"testing"
"time"

ww "github.com/grafana/dskit/server"
json "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/promtail/api"

Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/promtail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
serverww "github.com/grafana/dskit/server"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
Expand All @@ -28,7 +29,6 @@ import (
"github.com/prometheus/prometheus/promql/parser"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
serverww "github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/logentry/stages"
"github.com/grafana/loki/clients/pkg/promtail/client"
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/scrapeconfig/scrapeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/Shopify/sarama"
"github.com/grafana/dskit/flagext"

"github.com/grafana/dskit/server"
promconfig "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery"
Expand All @@ -25,7 +26,6 @@ import (
"github.com/prometheus/prometheus/discovery/triton"
"github.com/prometheus/prometheus/discovery/zookeeper"
"github.com/prometheus/prometheus/model/relabel"
"github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/logentry/stages"
"github.com/grafana/loki/clients/pkg/promtail/discovery/consulagent"
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"github.com/felixge/fgprof"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
serverww "github.com/grafana/dskit/server"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/version"
serverww "github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/promtail/server/ui"
"github.com/grafana/loki/clients/pkg/promtail/targets"
Expand Down
6 changes: 3 additions & 3 deletions clients/pkg/promtail/targets/gcplog/push_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
dslog "github.com/grafana/dskit/log"
"github.com/grafana/dskit/server"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/relabel"
"github.com/weaveworks/common/logging"
"github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/scrapeconfig"
Expand Down Expand Up @@ -80,7 +80,7 @@ func (h *pushTarget) run() error {
h.config.Server.RegisterInstrumentation = false

// Wrapping util logger with component-specific key vals, and the expected GoKit logging interface
h.config.Server.Log = logging.GoKit(log.With(util_log.Logger, "component", "gcp_push"))
h.config.Server.Log = dslog.GoKit(log.With(util_log.Logger, "component", "gcp_push"))

srv, err := server.New(h.config.Server)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/gcplog/push_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/api"

"github.com/go-kit/log"
"github.com/grafana/dskit/server"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/relabel"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/server"

lokiClient "github.com/grafana/loki/clients/pkg/promtail/client"
"github.com/grafana/loki/clients/pkg/promtail/client/fake"
Expand Down
6 changes: 3 additions & 3 deletions clients/pkg/promtail/targets/heroku/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
dslog "github.com/grafana/dskit/log"
"github.com/grafana/dskit/server"
herokuEncoding "github.com/heroku/x/logplex/encoding"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/relabel"
"github.com/weaveworks/common/logging"
"github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/promtail/api"
lokiClient "github.com/grafana/loki/clients/pkg/promtail/client"
Expand Down Expand Up @@ -80,7 +80,7 @@ func (h *Target) run() error {
h.config.Server.RegisterInstrumentation = false

// Wrapping util logger with component-specific key vals, and the expected GoKit logging interface
h.config.Server.Log = logging.GoKit(log.With(util_log.Logger, "component", "heroku_drain"))
h.config.Server.Log = dslog.GoKit(log.With(util_log.Logger, "component", "heroku_drain"))

srv, err := server.New(h.config.Server)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/heroku/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (

"github.com/go-kit/log"
"github.com/google/uuid"
"github.com/grafana/dskit/server"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/relabel"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/server"

lokiClient "github.com/grafana/loki/clients/pkg/promtail/client"
"github.com/grafana/loki/clients/pkg/promtail/client/fake"
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/lokipush/pushtarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/server"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/relabel"
promql_parser "github.com/prometheus/prometheus/promql/parser"
"github.com/weaveworks/common/server"

"github.com/grafana/dskit/tenant"

Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/lokipush/pushtarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (

"github.com/go-kit/log"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/server"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/relabel"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/server"

"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/client"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package lokipush
import (
"testing"

"github.com/weaveworks/common/server"
"github.com/grafana/dskit/server"

"github.com/grafana/loki/clients/pkg/promtail/scrapeconfig"
)
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/serverutils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package serverutils
import (
"flag"

"github.com/grafana/dskit/server"
"github.com/imdario/mergo"
"github.com/weaveworks/common/server"
)

// MergeWithDefaults applies server.Config defaults to a given and different server.Config.
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/windows/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"testing"
"time"

"github.com/grafana/dskit/server"
jsoniter "github.com/json-iterator/go"
"github.com/prometheus/common/model"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/server"
"golang.org/x/sys/windows/svc/eventlog"

"github.com/grafana/loki/clients/pkg/promtail/api"
Expand Down
2 changes: 1 addition & 1 deletion cmd/logql-analyzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/gorilla/mux"
"github.com/grafana/dskit/server"
"github.com/prometheus/client_golang/prometheus"
"github.com/weaveworks/common/server"

"github.com/grafana/loki/pkg/logqlanalyzer"
"github.com/grafana/loki/pkg/sizing"
Expand Down
Loading

0 comments on commit 796ae69

Please sign in to comment.