Skip to content

Commit

Permalink
Chore: Use runtimeconfig from dskit (#4227)
Browse files Browse the repository at this point in the history
* Use runtimeconfig from dskit

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* runtimeconfig: Use cortex_ prefix for metrics

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
aknuds1 authored Aug 31, 2021
1 parent 11a0d28 commit a5790f3
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 26 deletions.
40 changes: 20 additions & 20 deletions pkg/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"github.com/cortexproject/cortex/pkg/util/fakeauth"
"github.com/cortexproject/cortex/pkg/util/grpc/healthcheck"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/cortexproject/cortex/pkg/util/runtimeconfig"
"github.com/felixge/fgprof"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/modules"
"github.com/grafana/dskit/runtimeconfig"
"github.com/grafana/dskit/services"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -52,25 +52,25 @@ type Config struct {
AuthEnabled bool `yaml:"auth_enabled,omitempty"`
HTTPPrefix string `yaml:"http_prefix"`

Server server.Config `yaml:"server,omitempty"`
Distributor distributor.Config `yaml:"distributor,omitempty"`
Querier querier.Config `yaml:"querier,omitempty"`
IngesterClient client.Config `yaml:"ingester_client,omitempty"`
Ingester ingester.Config `yaml:"ingester,omitempty"`
StorageConfig storage.Config `yaml:"storage_config,omitempty"`
ChunkStoreConfig storage.ChunkStoreConfig `yaml:"chunk_store_config,omitempty"`
SchemaConfig storage.SchemaConfig `yaml:"schema_config,omitempty"`
LimitsConfig validation.Limits `yaml:"limits_config,omitempty"`
TableManager chunk.TableManagerConfig `yaml:"table_manager,omitempty"`
Worker worker.Config `yaml:"frontend_worker,omitempty"`
Frontend lokifrontend.Config `yaml:"frontend,omitempty"`
Ruler ruler.Config `yaml:"ruler,omitempty"`
QueryRange queryrange.Config `yaml:"query_range,omitempty"`
RuntimeConfig runtimeconfig.ManagerConfig `yaml:"runtime_config,omitempty"`
MemberlistKV memberlist.KVConfig `yaml:"memberlist"`
Tracing tracing.Config `yaml:"tracing"`
CompactorConfig compactor.Config `yaml:"compactor,omitempty"`
QueryScheduler scheduler.Config `yaml:"query_scheduler"`
Server server.Config `yaml:"server,omitempty"`
Distributor distributor.Config `yaml:"distributor,omitempty"`
Querier querier.Config `yaml:"querier,omitempty"`
IngesterClient client.Config `yaml:"ingester_client,omitempty"`
Ingester ingester.Config `yaml:"ingester,omitempty"`
StorageConfig storage.Config `yaml:"storage_config,omitempty"`
ChunkStoreConfig storage.ChunkStoreConfig `yaml:"chunk_store_config,omitempty"`
SchemaConfig storage.SchemaConfig `yaml:"schema_config,omitempty"`
LimitsConfig validation.Limits `yaml:"limits_config,omitempty"`
TableManager chunk.TableManagerConfig `yaml:"table_manager,omitempty"`
Worker worker.Config `yaml:"frontend_worker,omitempty"`
Frontend lokifrontend.Config `yaml:"frontend,omitempty"`
Ruler ruler.Config `yaml:"ruler,omitempty"`
QueryRange queryrange.Config `yaml:"query_range,omitempty"`
RuntimeConfig runtimeconfig.Config `yaml:"runtime_config,omitempty"`
MemberlistKV memberlist.KVConfig `yaml:"memberlist"`
Tracing tracing.Config `yaml:"tracing"`
CompactorConfig compactor.Config `yaml:"compactor,omitempty"`
QueryScheduler scheduler.Config `yaml:"query_scheduler"`
}

// RegisterFlags registers flag.
Expand Down
4 changes: 2 additions & 2 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/cortexproject/cortex/pkg/scheduler"
"github.com/cortexproject/cortex/pkg/scheduler/schedulerpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/cortexproject/cortex/pkg/util/runtimeconfig"
"github.com/go-kit/kit/log/level"
"github.com/grafana/dskit/runtimeconfig"
"github.com/grafana/dskit/services"
"github.com/prometheus/client_golang/prometheus"
httpgrpc_server "github.com/weaveworks/common/httpgrpc/server"
Expand Down Expand Up @@ -149,7 +149,7 @@ func (t *Loki) initRuntimeConfig() (services.Service, error) {
validation.SetDefaultLimitsForYAMLUnmarshalling(t.Cfg.LimitsConfig)

var err error
t.runtimeConfig, err = runtimeconfig.NewRuntimeConfigManager(t.Cfg.RuntimeConfig, prometheus.DefaultRegisterer)
t.runtimeConfig, err = runtimeconfig.New(t.Cfg.RuntimeConfig, prometheus.WrapRegistererWithPrefix("cortex_", prometheus.DefaultRegisterer), util_log.Logger)
return t.runtimeConfig, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/loki/runtime_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"

"github.com/cortexproject/cortex/pkg/ring/kv"
"github.com/cortexproject/cortex/pkg/util/runtimeconfig"
"github.com/grafana/dskit/runtimeconfig"
"gopkg.in/yaml.v2"

"github.com/grafana/loki/pkg/runtime"
Expand Down
7 changes: 4 additions & 3 deletions pkg/loki/runtime_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"testing"
"time"

"github.com/cortexproject/cortex/pkg/util/runtimeconfig"
"github.com/go-kit/kit/log"
"github.com/grafana/dskit/runtimeconfig"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
Expand Down Expand Up @@ -91,7 +92,7 @@ func newTestOverrides(t *testing.T, yaml string) *validation.Overrides {
loader := func(_ io.Reader) (interface{}, error) {
return loadRuntimeConfig(strings.NewReader(yaml))
}
cfg := runtimeconfig.ManagerConfig{
cfg := runtimeconfig.Config{
ReloadPeriod: 1 * time.Second,
Loader: loader,
LoadPath: path,
Expand All @@ -102,7 +103,7 @@ func newTestOverrides(t *testing.T, yaml string) *validation.Overrides {
require.NoError(t, flagset.Parse(nil))
validation.SetDefaultLimitsForYAMLUnmarshalling(defaults)

runtimeConfig, err := runtimeconfig.NewRuntimeConfigManager(cfg, prometheus.DefaultRegisterer)
runtimeConfig, err := runtimeconfig.New(cfg, prometheus.WrapRegistererWithPrefix("cortex_", prometheus.DefaultRegisterer), log.NewNopLogger())
require.NoError(t, err)

require.NoError(t, runtimeConfig.StartAsync(context.Background()))
Expand Down
210 changes: 210 additions & 0 deletions vendor/github.com/grafana/dskit/runtimeconfig/manager.go

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
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ github.com/gorilla/websocket
github.com/grafana/dskit/backoff
github.com/grafana/dskit/flagext
github.com/grafana/dskit/modules
github.com/grafana/dskit/runtimeconfig
github.com/grafana/dskit/services
# github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
## explicit
Expand Down

0 comments on commit a5790f3

Please sign in to comment.