Skip to content

Commit

Permalink
Add option to completely skip the create metric descriptor logic. (#25)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Oct 11, 2019
1 parent a662bb1 commit 272725c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions exporter/stackdriverexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ type Config struct {
Prefix string `mapstructure:"metric-prefix"`
Endpoint string `mapstructure:"endpoint"`
NumOfWorkers int `mapstructure:"number-of-workers"`
SkipCreateMetricDescriptor bool `mapstructure:"skip-create-metric-descriptor"`
}
10 changes: 6 additions & 4 deletions exporter/stackdriverexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ func TestLoadConfig(t *testing.T) {
r1 := cfg.Exporters["stackdriver/customname"].(*Config)
assert.Equal(t, r1,
&Config{
ExporterSettings: configmodels.ExporterSettings{TypeVal: typeStr, NameVal: "stackdriver/customname"},
ProjectID: "my-project",
Prefix: "prefix",
Endpoint: "test-endpoint",
ExporterSettings: configmodels.ExporterSettings{TypeVal: typeStr, NameVal: "stackdriver/customname"},
ProjectID: "my-project",
Prefix: "prefix",
Endpoint: "test-endpoint",
NumOfWorkers: 3,
SkipCreateMetricDescriptor: true,
})
}
3 changes: 3 additions & 0 deletions exporter/stackdriverexporter/stackdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func newStackdriverMetricsExporter(cfg *Config) (exporter.MetricsExporter, error
if cfg.NumOfWorkers > 0 {
options.NumberOfWorkers = cfg.NumOfWorkers
}
if cfg.SkipCreateMetricDescriptor {
options.SkipCMD = true
}
sde, serr := stackdriver.NewExporter(options)
if serr != nil {
return nil, fmt.Errorf("cannot configure Stackdriver metric exporter: %v", serr)
Expand Down
2 changes: 2 additions & 0 deletions exporter/stackdriverexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ exporters:
project: my-project
metric-prefix: prefix
endpoint: test-endpoint
number-of-workers: 3
skip-create-metric-descriptor: true
stackdriver/disabled: # will be ignored
disabled: true

Expand Down

0 comments on commit 272725c

Please sign in to comment.