Skip to content

Commit e52d6be

Browse files
authored
[exporter/datadog] Deprecate service and version settings (open-telemetry#8784)
* [exporter/datadog] Deprecate `service` and `version` settings * Add changelog entry * [exporter/datadog] Remove Service and Version from tests * Address review comment * Fix lint * Bump to v0.49.0 This won't make it into v0.48.0, so I updated the deprecation and removal versions * Update CHANGELOG
1 parent 5f777db commit e52d6be

File tree

6 files changed

+58
-55
lines changed

6 files changed

+58
-55
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
### 🚩 Deprecations 🚩
1717

18+
- `datadogexporter`: Deprecate `service` setting in favor of `service.name` semantic convention (#8784)
19+
- `datadogexporter`: Deprecate `version` setting in favor of `service.version` semantic convention (#8784)
20+
1821
### 🚀 New components 🚀
1922

2023
## v0.48.0

exporter/datadogexporter/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ exporters:
6969
datadog/api:
7070
hostname: customhostname
7171
env: prod
72-
service: myservice
73-
version: myversion
7472
7573
tags:
7674
- example:tag

exporter/datadogexporter/config/config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,14 @@ type TagsConfig struct {
221221
Env string `mapstructure:"env"`
222222

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

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

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

421+
deprecationTemplate := "%q has been deprecated and will be removed in %s. See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/%d"
422+
if c.Service != "" {
423+
c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "service", "v0.52.0", 8781))
424+
}
425+
if c.Version != "" {
426+
c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "version", "v0.52.0", 8783))
427+
}
428+
417429
return nil
418430
}

exporter/datadogexporter/example/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ exporters:
2121

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

2830
## @param version - string - optional
2931
## The version for unified service tagging.
32+
## Deprecated: [v0.48.0] Set `service.version` semconv instead, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/8783 for details.
33+
## This option will be removed in v0.51.0.
3034
## If unset it will be determined from the `DD_VERSION` environment variable (Deprecated: [v0.47.0] set environment variable explicitly on configuration instead).
3135
#
3236
# version: myversion

exporter/datadogexporter/factory_test.go

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -130,53 +130,47 @@ func TestLoadConfig(t *testing.T) {
130130
err = apiConfig.Sanitize(zap.NewNop())
131131

132132
require.NoError(t, err)
133-
assert.Equal(t, &ddconfig.Config{
134-
ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "api")),
135-
TimeoutSettings: defaulttimeoutSettings(),
136-
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
137-
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
138-
139-
TagsConfig: ddconfig.TagsConfig{
140-
Hostname: "customhostname",
141-
Env: "prod",
142-
Service: "myservice",
143-
Version: "myversion",
144-
EnvVarTags: "",
145-
Tags: []string{"example:tag"},
133+
assert.Equal(t, config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "api")), apiConfig.ExporterSettings)
134+
assert.Equal(t, defaulttimeoutSettings(), apiConfig.TimeoutSettings)
135+
assert.Equal(t, exporterhelper.NewDefaultRetrySettings(), apiConfig.RetrySettings)
136+
assert.Equal(t, exporterhelper.NewDefaultQueueSettings(), apiConfig.QueueSettings)
137+
assert.Equal(t, ddconfig.TagsConfig{
138+
Hostname: "customhostname",
139+
Env: "prod",
140+
Service: "myservice",
141+
Version: "myversion",
142+
EnvVarTags: "",
143+
Tags: []string{"example:tag"},
144+
}, apiConfig.TagsConfig)
145+
assert.Equal(t, ddconfig.APIConfig{
146+
Key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
147+
Site: "datadoghq.eu",
148+
}, apiConfig.API)
149+
assert.Equal(t, ddconfig.MetricsConfig{
150+
TCPAddr: confignet.TCPAddr{
151+
Endpoint: "https://api.datadoghq.eu",
146152
},
147-
148-
API: ddconfig.APIConfig{
149-
Key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
150-
Site: "datadoghq.eu",
153+
DeltaTTL: 3600,
154+
SendMonotonic: true,
155+
Quantiles: true,
156+
HistConfig: ddconfig.HistogramConfig{
157+
Mode: "distributions",
158+
SendCountSum: false,
151159
},
152-
153-
Metrics: ddconfig.MetricsConfig{
154-
TCPAddr: confignet.TCPAddr{
155-
Endpoint: "https://api.datadoghq.eu",
156-
},
157-
DeltaTTL: 3600,
158-
SendMonotonic: true,
159-
Quantiles: true,
160-
HistConfig: ddconfig.HistogramConfig{
161-
Mode: "distributions",
162-
SendCountSum: false,
163-
},
164-
SumConfig: ddconfig.SumConfig{
165-
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
166-
},
160+
SumConfig: ddconfig.SumConfig{
161+
CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta,
167162
},
168-
169-
Traces: ddconfig.TracesConfig{
170-
SampleRate: 1,
171-
TCPAddr: confignet.TCPAddr{
172-
Endpoint: "https://trace.agent.datadoghq.eu",
173-
},
174-
IgnoreResources: []string{},
163+
}, apiConfig.Metrics)
164+
assert.Equal(t, ddconfig.TracesConfig{
165+
SampleRate: 1,
166+
TCPAddr: confignet.TCPAddr{
167+
Endpoint: "https://trace.agent.datadoghq.eu",
175168
},
176-
SendMetadata: true,
177-
OnlyMetadata: false,
178-
UseResourceMetadata: true,
179-
}, apiConfig)
169+
IgnoreResources: []string{},
170+
}, apiConfig.Traces)
171+
assert.True(t, apiConfig.SendMetadata)
172+
assert.False(t, apiConfig.OnlyMetadata)
173+
assert.True(t, apiConfig.UseResourceMetadata)
180174

181175
defaultConfig := cfg.Exporters[config.NewComponentIDWithName(typeStr, "default")].(*ddconfig.Config)
182176
err = defaultConfig.Sanitize(zap.NewNop())
@@ -240,8 +234,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
240234
assert.NoError(t, os.Setenv("DD_API_KEY", "replacedapikey"))
241235
assert.NoError(t, os.Setenv("DD_HOST", "testhost"))
242236
assert.NoError(t, os.Setenv("DD_ENV", "testenv"))
243-
assert.NoError(t, os.Setenv("DD_SERVICE", "testservice"))
244-
assert.NoError(t, os.Setenv("DD_VERSION", "testversion"))
245237
assert.NoError(t, os.Setenv("DD_SITE", "datadoghq.test"))
246238
assert.NoError(t, os.Setenv("DD_TAGS", "envexample:tag envexample2:tag"))
247239
assert.NoError(t, os.Setenv("DD_URL", "https://api.datadoghq.com"))
@@ -251,8 +243,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
251243
assert.NoError(t, os.Unsetenv("DD_API_KEY"))
252244
assert.NoError(t, os.Unsetenv("DD_HOST"))
253245
assert.NoError(t, os.Unsetenv("DD_ENV"))
254-
assert.NoError(t, os.Unsetenv("DD_SERVICE"))
255-
assert.NoError(t, os.Unsetenv("DD_VERSION"))
256246
assert.NoError(t, os.Unsetenv("DD_SITE"))
257247
assert.NoError(t, os.Unsetenv("DD_TAGS"))
258248
assert.NoError(t, os.Unsetenv("DD_URL"))
@@ -281,8 +271,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
281271
assert.Equal(t, ddconfig.TagsConfig{
282272
Hostname: "customhostname",
283273
Env: "prod",
284-
Service: "myservice",
285-
Version: "myversion",
286274
EnvVarTags: "envexample:tag envexample2:tag",
287275
Tags: []string{"example:tag"},
288276
}, apiConfig.TagsConfig)
@@ -330,8 +318,6 @@ func TestLoadConfigEnvVariables(t *testing.T) {
330318
assert.Equal(t, ddconfig.TagsConfig{
331319
Hostname: "testhost",
332320
Env: "testenv",
333-
Service: "testservice",
334-
Version: "testversion",
335321
EnvVarTags: "envexample:tag envexample2:tag",
336322
}, defaultConfig.TagsConfig)
337323
assert.Equal(t, ddconfig.APIConfig{

exporter/datadogexporter/testdata/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ exporters:
88
datadog/api:
99
hostname: customhostname
1010
env: prod
11+
# Deprecated; kept here to avoid regressions.
1112
service: myservice
13+
# Deprecated; kept here to avoid regressions.
1214
version: myversion
1315

1416
tags:
@@ -24,8 +26,6 @@ exporters:
2426
datadog/api2:
2527
hostname: customhostname
2628
env: prod
27-
service: myservice
28-
version: myversion
2929

3030
tags:
3131
- example:tag

0 commit comments

Comments
 (0)