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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
### 🚩 Deprecations 🚩

- `datadogexporter`: Deprecate `OnlyMetadata` method from `Config` struct (#8359)
- `datadogexporter`: Deprecate `service` setting in favor of `service.name` semantic convention (#8784)
- `datadogexporter`: Deprecate `version` setting in favor of `service.version` semantic convention (#8784)

## v0.47.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 @@ -175,10 +175,14 @@ type TagsConfig struct {
Env string `mapstructure:"env"`

// Service is 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.
// 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.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.
// 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 @@ -361,5 +365,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.51", 8781))
}
if c.Version != "" {
c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "version", "v0.51", 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
10 changes: 0 additions & 10 deletions exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ func TestLoadConfig(t *testing.T) {
TagsConfig: ddconfig.TagsConfig{
Hostname: "customhostname",
Env: "prod",
Service: "myservice",
Version: "myversion",
EnvVarTags: "",
Tags: []string{"example:tag"},
},
Expand Down Expand Up @@ -231,8 +229,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 @@ -242,8 +238,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 @@ -272,8 +266,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 @@ -318,8 +310,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: 0 additions & 4 deletions exporter/datadogexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ exporters:
datadog/api:
hostname: customhostname
env: prod
service: myservice
version: myversion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're deprecating these options, but they're technically still supported until v0.51.0. Should we keep the tests until we definitely remove these options (to prevent breaking the behavior of these options before the scheduled date)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added back this with a comment stating they are deprecated. I didn't do this originally because you need to check Config fields individually until we do #8373 (since the warnings field is unexported)


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

tags:
- example:tag
Expand Down