Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/datadog] Deprecate service and version settings #8784

Merged
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

### 🚩 Deprecations 🚩

- `datadogexporter`: Deprecate `service` setting in favor of `service.name` semantic convention (#8784)
- `datadogexporter`: Deprecate `version` setting in favor of `service.version` semantic convention (#8784)

### 🚀 New components 🚀

## v0.48.0
Expand Down
2 changes: 0 additions & 2 deletions exporter/datadogexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ exporters:
datadog/api:
hostname: customhostname
env: prod
service: myservice
version: myversion

tags:
- example:tag
Expand Down
12 changes: 12 additions & 0 deletions exporter/datadogexporter/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,14 @@ type TagsConfig struct {
Env string `mapstructure:"env"`

// Service is the service for unified service tagging.
// Deprecated: [v0.49.0] Set `service.name` semconv instead, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/8781 for details.
// This option will be removed in v0.52.0.
// It can also be set through the `DD_SERVICE` environment variable (Deprecated: [v0.47.0] set environment variable explicitly on configuration instead).
Service string `mapstructure:"service"`

// Version is the version for unified service tagging.
// Deprecated: [v0.49.0] Set `service.version` semconv instead, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/8783 for details.
// This option will be removed in v0.52.0.
// It can also be set through the `DD_VERSION` environment variable (Deprecated: [v0.47.0] set environment variable explicitly on configuration instead).
Version string `mapstructure:"version"`

Expand Down Expand Up @@ -414,5 +418,13 @@ func (c *Config) Unmarshal(configMap *config.Map) error {
// Add warnings about autodetected environment variables.
c.warnings = append(c.warnings, warnUseOfEnvVars(configMap, c)...)

deprecationTemplate := "%q has been deprecated and will be removed in %s. See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/%d"
if c.Service != "" {
c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "service", "v0.52.0", 8781))
}
if c.Version != "" {
c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "version", "v0.52.0", 8783))
}

return nil
}
4 changes: 4 additions & 0 deletions exporter/datadogexporter/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ exporters:

## @param service - string - optional
## The service for unified service tagging.
## Deprecated: [v0.48.0] Set `service.name` semconv instead, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/8781 for details.
## This option will be removed in v0.51.0.
## If unset it will be determined from the `DD_SERVICE` environment variable (Deprecated: [v0.47.0] set environment variable explicitly on configuration instead).
#
# service: myservice

## @param version - string - optional
## The version for unified service tagging.
## Deprecated: [v0.48.0] Set `service.version` semconv instead, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/8783 for details.
## This option will be removed in v0.51.0.
## If unset it will be determined from the `DD_VERSION` environment variable (Deprecated: [v0.47.0] set environment variable explicitly on configuration instead).
#
# version: myversion
Expand Down
88 changes: 37 additions & 51 deletions exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,53 +130,47 @@ func TestLoadConfig(t *testing.T) {
err = apiConfig.Sanitize(zap.NewNop())

require.NoError(t, err)
assert.Equal(t, &ddconfig.Config{
ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "api")),
TimeoutSettings: defaulttimeoutSettings(),
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),

TagsConfig: ddconfig.TagsConfig{
Hostname: "customhostname",
Env: "prod",
Service: "myservice",
Version: "myversion",
EnvVarTags: "",
Tags: []string{"example:tag"},
assert.Equal(t, config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "api")), apiConfig.ExporterSettings)
assert.Equal(t, defaulttimeoutSettings(), apiConfig.TimeoutSettings)
assert.Equal(t, exporterhelper.NewDefaultRetrySettings(), apiConfig.RetrySettings)
assert.Equal(t, exporterhelper.NewDefaultQueueSettings(), apiConfig.QueueSettings)
assert.Equal(t, ddconfig.TagsConfig{
Hostname: "customhostname",
Env: "prod",
Service: "myservice",
Version: "myversion",
EnvVarTags: "",
Tags: []string{"example:tag"},
}, apiConfig.TagsConfig)
assert.Equal(t, ddconfig.APIConfig{
Key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
Site: "datadoghq.eu",
}, apiConfig.API)
assert.Equal(t, ddconfig.MetricsConfig{
TCPAddr: confignet.TCPAddr{
Endpoint: "https://api.datadoghq.eu",
},

API: ddconfig.APIConfig{
Key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
Site: "datadoghq.eu",
DeltaTTL: 3600,
SendMonotonic: true,
Quantiles: true,
HistConfig: ddconfig.HistogramConfig{
Mode: "distributions",
SendCountSum: false,
},

Metrics: ddconfig.MetricsConfig{
TCPAddr: confignet.TCPAddr{
Endpoint: "https://api.datadoghq.eu",
},
DeltaTTL: 3600,
SendMonotonic: true,
Quantiles: true,
HistConfig: ddconfig.HistogramConfig{
Mode: "distributions",
SendCountSum: false,
},
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},
SumConfig: ddconfig.SumConfig{
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
},

Traces: ddconfig.TracesConfig{
SampleRate: 1,
TCPAddr: confignet.TCPAddr{
Endpoint: "https://trace.agent.datadoghq.eu",
},
IgnoreResources: []string{},
}, apiConfig.Metrics)
assert.Equal(t, ddconfig.TracesConfig{
SampleRate: 1,
TCPAddr: confignet.TCPAddr{
Endpoint: "https://trace.agent.datadoghq.eu",
},
SendMetadata: true,
OnlyMetadata: false,
UseResourceMetadata: true,
}, apiConfig)
IgnoreResources: []string{},
}, apiConfig.Traces)
assert.True(t, apiConfig.SendMetadata)
assert.False(t, apiConfig.OnlyMetadata)
assert.True(t, apiConfig.UseResourceMetadata)

defaultConfig := cfg.Exporters[config.NewComponentIDWithName(typeStr, "default")].(*ddconfig.Config)
err = defaultConfig.Sanitize(zap.NewNop())
Expand Down Expand Up @@ -240,8 +234,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
assert.NoError(t, os.Setenv("DD_API_KEY", "replacedapikey"))
assert.NoError(t, os.Setenv("DD_HOST", "testhost"))
assert.NoError(t, os.Setenv("DD_ENV", "testenv"))
assert.NoError(t, os.Setenv("DD_SERVICE", "testservice"))
assert.NoError(t, os.Setenv("DD_VERSION", "testversion"))
assert.NoError(t, os.Setenv("DD_SITE", "datadoghq.test"))
assert.NoError(t, os.Setenv("DD_TAGS", "envexample:tag envexample2:tag"))
assert.NoError(t, os.Setenv("DD_URL", "https://api.datadoghq.com"))
Expand All @@ -251,8 +243,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
assert.NoError(t, os.Unsetenv("DD_API_KEY"))
assert.NoError(t, os.Unsetenv("DD_HOST"))
assert.NoError(t, os.Unsetenv("DD_ENV"))
assert.NoError(t, os.Unsetenv("DD_SERVICE"))
assert.NoError(t, os.Unsetenv("DD_VERSION"))
assert.NoError(t, os.Unsetenv("DD_SITE"))
assert.NoError(t, os.Unsetenv("DD_TAGS"))
assert.NoError(t, os.Unsetenv("DD_URL"))
Expand Down Expand Up @@ -281,8 +271,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
assert.Equal(t, ddconfig.TagsConfig{
Hostname: "customhostname",
Env: "prod",
Service: "myservice",
Version: "myversion",
EnvVarTags: "envexample:tag envexample2:tag",
Tags: []string{"example:tag"},
}, apiConfig.TagsConfig)
Expand Down Expand Up @@ -330,8 +318,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
assert.Equal(t, ddconfig.TagsConfig{
Hostname: "testhost",
Env: "testenv",
Service: "testservice",
Version: "testversion",
EnvVarTags: "envexample:tag envexample2:tag",
}, defaultConfig.TagsConfig)
assert.Equal(t, ddconfig.APIConfig{
Expand Down
4 changes: 2 additions & 2 deletions exporter/datadogexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ exporters:
datadog/api:
hostname: customhostname
env: prod
# Deprecated; kept here to avoid regressions.
service: myservice
# Deprecated; kept here to avoid regressions.
version: myversion

tags:
Expand All @@ -24,8 +26,6 @@ exporters:
datadog/api2:
hostname: customhostname
env: prod
service: myservice
version: myversion

tags:
- example:tag
Expand Down