Skip to content

Commit

Permalink
exporter/signalfx: Update exclude_metrics option (open-telemetry#2737)
Browse files Browse the repository at this point in the history
  • Loading branch information
asuresh4 committed Mar 19, 2021
1 parent 3254370 commit deb6efe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 4 additions & 1 deletion exporter/signalfxexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ The following configuration options can also be configured:
- `exclude_metrics`: List of metric filters that will determine metrics to be
excluded from sending to Signalfx backend. If `translation_rules` options
are enabled, the exclusion will be applied on translated metrics.
See [here](./testdata/config.yaml) for examples.
See [here](./testdata/config.yaml) for examples. Apart from the values explicitly
provided via this option, by default, [these](./translation/default_metrics.go) are
also appended to this list. Setting this option to `[]` will override all the default
excludes.
- `include_metrics`: List of filters to override exclusion of any metrics.
This option can be used to included metrics that are otherwise dropped by
default. See [here](./translation/default_metrics.go) for a list of metrics
Expand Down
4 changes: 1 addition & 3 deletions exporter/signalfxexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ func setDefaultExcludes(cfg *Config) error {
if err != nil {
return err
}
if cfg.ExcludeMetrics == nil {
cfg.ExcludeMetrics = defaultExcludeMetrics
} else {
if cfg.ExcludeMetrics == nil || len(cfg.ExcludeMetrics) > 0 {
cfg.ExcludeMetrics = append(cfg.ExcludeMetrics, defaultExcludeMetrics...)
}
return nil
Expand Down
20 changes: 20 additions & 0 deletions exporter/signalfxexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,26 @@ func TestCreateMetricsExporterWithExcludeMetrics(t *testing.T) {
assert.Equal(t, 11, len(config.ExcludeMetrics))
}

func TestCreateMetricsExporterWithEmptyExcludeMetrics(t *testing.T) {
config := &Config{
ExporterSettings: configmodels.ExporterSettings{
TypeVal: configmodels.Type(typeStr),
NameVal: typeStr,
},
AccessToken: "testToken",
Realm: "us1",
ExcludeMetrics: []dpfilters.MetricFilter{},
}

te, err := createMetricsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, config)
require.NoError(t, err)
require.NotNil(t, te)

// Validate that default excludes are overridden when exclude metrics
// is explicitly set to an empty slice.
assert.Equal(t, 0, len(config.ExcludeMetrics))
}

func testMetricsData() pdata.ResourceMetrics {
md := internaldata.MetricsData{
Metrics: []*metricspb.Metric{
Expand Down

0 comments on commit deb6efe

Please sign in to comment.