Skip to content

Commit

Permalink
Mutate - to _ in component names for metrics (#1145) (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmorie authored Mar 6, 2020
1 parent 122514b commit a56a6ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion metrics/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package metrics
import (
"errors"
"fmt"
"strings"
"sync"

"go.opencensus.io/stats/view"
Expand Down Expand Up @@ -74,7 +75,7 @@ func UpdateExporterFromConfigMap(component string, logger *zap.SugaredLogger) fu
return func(configMap *corev1.ConfigMap) {
UpdateExporter(ExporterOptions{
Domain: domain,
Component: component,
Component: strings.ReplaceAll(component, "-", "_"),
ConfigMap: configMap.Data,
}, logger)
}
Expand Down
11 changes: 11 additions & 0 deletions metrics/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ func TestMetricsExporter(t *testing.T) {
},
},
expectSuccess: true,
}, {
name: "validConfigWithDashInName",
config: &metricsConfig{
domain: servingDomain,
component: "test-component",
backendDestination: Stackdriver,
stackdriverClientConfig: StackdriverClientConfig{
ProjectID: "testProj",
},
},
expectSuccess: true,
}, {
name: "stackdriverConfigOnly",
config: &metricsConfig{
Expand Down

0 comments on commit a56a6ea

Please sign in to comment.