Skip to content

Commit

Permalink
Pick latest flytestdlib with metric name sanitization (flyteorg#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumare3 authored Feb 10, 2022
1 parent 7e8bc5f commit 02b1ed7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
8 changes: 1 addition & 7 deletions cmd/controller/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"runtime"
"runtime/pprof"
"strings"

"github.com/flyteorg/flytestdlib/contextutils"

Expand Down Expand Up @@ -151,11 +150,6 @@ func sharedInformerOptions(cfg *config2.Config) []informers.SharedInformerOption
return opts
}

func safeMetricName(original string) string {
// TODO: Replace all non-prom-compatible charset
return strings.Replace(original, "-", "_", -1)
}

func executeRootCmd(cfg *config2.Config) {
baseCtx := context.Background()

Expand All @@ -176,7 +170,7 @@ func executeRootCmd(cfg *config2.Config) {
flyteworkflowInformerFactory := informers.NewSharedInformerFactoryWithOptions(flyteworkflowClient, cfg.WorkflowReEval.Duration, opts...)

// Add the propeller subscope because the MetricsPrefix only has "flyte:" to get uniform collection of metrics.
propellerScope := promutils.NewScope(cfg.MetricsPrefix).NewSubScope("propeller").NewSubScope(safeMetricName(cfg.LimitNamespace))
propellerScope := promutils.NewScope(cfg.MetricsPrefix).NewSubScope("propeller").NewSubScope(cfg.LimitNamespace)

go func() {
err := profutils.StartProfilingServerWithDefaultHandlers(ctx, cfg.ProfilerPort.Port, nil)
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller/cmd/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func runWebhook(origContext context.Context, propellerCfg *config.Config, cfg *w
}

// Add the propeller subscope because the MetricsPrefix only has "flyte:" to get uniform collection of metrics.
propellerScope := promutils.NewScope(cfg.MetricsPrefix).NewSubScope("propeller").NewSubScope(safeMetricName(propellerCfg.LimitNamespace))
propellerScope := promutils.NewScope(cfg.MetricsPrefix).NewSubScope("propeller").NewSubScope(propellerCfg.LimitNamespace)
webhookScope := propellerScope.NewSubScope("webhook")

go func() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/fatih/color v1.10.0
github.com/flyteorg/flyteidl v0.22.0
github.com/flyteorg/flyteplugins v0.10.3
github.com/flyteorg/flytestdlib v0.4.7
github.com/flyteorg/flytestdlib v0.4.12
github.com/ghodss/yaml v1.0.0
github.com/go-redis/redis v6.15.7+incompatible
github.com/go-test/deep v1.0.7
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ github.com/flyteorg/flyteplugins v0.10.3/go.mod h1:RXgHGGUGC1akEnAd0yi4cLuYP1BF1
github.com/flyteorg/flytestdlib v0.3.13/go.mod h1:Tz8JCECAbX6VWGwFT6cmEQ+RJpZ/6L9pswu3fzWs220=
github.com/flyteorg/flytestdlib v0.4.7 h1:SMPPXI3j/MjP7D2fqaR+lPQkTrqYS7xZbwsgJI2F8SU=
github.com/flyteorg/flytestdlib v0.4.7/go.mod h1:fv1ar34LJLMTaf0tbfetisLykUlARi7rP+NQTUn6QQs=
github.com/flyteorg/flytestdlib v0.4.11 h1:Ahb/YdowkyLIunC5g0NiUOcXoxz5cS2SRhVn3SznJQ8=
github.com/flyteorg/flytestdlib v0.4.11/go.mod h1:fv1ar34LJLMTaf0tbfetisLykUlARi7rP+NQTUn6QQs=
github.com/flyteorg/flytestdlib v0.4.12 h1:e88Tcu+8ug6T2tzzxRltbsuBkcz4coAquF9xqwIrmLw=
github.com/flyteorg/flytestdlib v0.4.12/go.mod h1:fv1ar34LJLMTaf0tbfetisLykUlARi7rP+NQTUn6QQs=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/nodes/task/setup_ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ func Test_nameSpacedSetupCtx_MetricsScope(t *testing.T) {
ns := newNameSpacedSetupCtx(&setupContext{SetupContext: &dummySetupCtx{testScopeName: "test-scope-1"}}, r, "p1")
scope := ns.MetricsScope()
assert.NotNil(t, scope)
assert.Equal(t, "test-scope-1:p1:", scope.CurrentScope())
assert.Equal(t, "test_scope_1:p1:", scope.CurrentScope())
}

0 comments on commit 02b1ed7

Please sign in to comment.