Skip to content

[exporter/datadog] Deprecate env setting #9017

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

Merged
merged 4 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

- `datadogexporter`: Deprecate `service` setting in favor of `service.name` semantic convention (#8784)
- `datadogexporter`: Deprecate `version` setting in favor of `service.version` semantic convention (#8784)
- `datadogexporter`: Deprecate `env` setting in favor of `deployment.environment` semantic convention (#9017)
- `datadogexporter`: Deprecate `GetHostTags` method from `TagsConfig` struct (#8975)

### 🚀 New components 🚀
Expand Down
1 change: 0 additions & 1 deletion exporter/datadogexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ processors:
exporters:
datadog/api:
hostname: customhostname
env: prod

tags:
- example:tag
Expand Down
5 changes: 5 additions & 0 deletions exporter/datadogexporter/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ type TagsConfig struct {
Hostname string `mapstructure:"hostname"`

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

Expand Down Expand Up @@ -406,6 +408,9 @@ func (c *Config) Unmarshal(configMap *config.Map) error {
if c.Version != "" {
c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "version", "v0.52.0", 8783))
}
if c.Env != "" {
c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "env", "v0.52.0", 9016))
Copy link
Member Author

Choose a reason for hiding this comment

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

(the warning on the previous message comes from here)

Copy link
Contributor

Choose a reason for hiding this comment

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

That is super cool :D

}

return nil
}
10 changes: 6 additions & 4 deletions exporter/datadogexporter/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@ exporters:

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

## @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.
## 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.
## 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.
## 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.
## 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
6 changes: 2 additions & 4 deletions exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ func TestLoadConfig(t *testing.T) {
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_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,7 +241,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
defer func() {
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_SITE"))
assert.NoError(t, os.Unsetenv("DD_TAGS"))
assert.NoError(t, os.Unsetenv("DD_URL"))
Expand Down Expand Up @@ -270,7 +268,7 @@ func TestLoadConfigEnvVariables(t *testing.T) {
assert.Equal(t, exporterhelper.NewDefaultQueueSettings(), apiConfig.QueueSettings)
assert.Equal(t, ddconfig.TagsConfig{
Hostname: "customhostname",
Env: "prod",
Env: "none",
EnvVarTags: "envexample:tag envexample2:tag",
Tags: []string{"example:tag"},
}, apiConfig.TagsConfig)
Expand Down Expand Up @@ -317,7 +315,7 @@ func TestLoadConfigEnvVariables(t *testing.T) {
assert.Equal(t, exporterhelper.NewDefaultQueueSettings(), defaultConfig.QueueSettings)
assert.Equal(t, ddconfig.TagsConfig{
Hostname: "testhost",
Env: "testenv",
Env: "none",
EnvVarTags: "envexample:tag envexample2:tag",
}, defaultConfig.TagsConfig)
assert.Equal(t, ddconfig.APIConfig{
Expand Down
3 changes: 1 addition & 2 deletions exporter/datadogexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ processors:
exporters:
datadog/api:
hostname: customhostname
# Deprecated; kept here to avoid regressions.
env: prod
# Deprecated; kept here to avoid regressions.
service: myservice
Expand All @@ -25,8 +26,6 @@ exporters:

datadog/api2:
hostname: customhostname
env: prod

tags:
- example:tag

Expand Down