From b7c6da92ff61ec900ff3ed10400b459e65eb2023 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 22 Mar 2022 13:27:38 +0100 Subject: [PATCH 1/7] [exporter/datadog] Deprecate `service` and `version` settings --- exporter/datadogexporter/README.md | 2 -- exporter/datadogexporter/config/config.go | 12 ++++++++++++ exporter/datadogexporter/example/config.yaml | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/exporter/datadogexporter/README.md b/exporter/datadogexporter/README.md index e9cef58defb2..efc5a2a5e780 100644 --- a/exporter/datadogexporter/README.md +++ b/exporter/datadogexporter/README.md @@ -69,8 +69,6 @@ exporters: datadog/api: hostname: customhostname env: prod - service: myservice - version: myversion tags: - example:tag diff --git a/exporter/datadogexporter/config/config.go b/exporter/datadogexporter/config/config.go index 81da4be2456a..ffcd765e752f 100644 --- a/exporter/datadogexporter/config/config.go +++ b/exporter/datadogexporter/config/config.go @@ -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"` @@ -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 } diff --git a/exporter/datadogexporter/example/config.yaml b/exporter/datadogexporter/example/config.yaml index e8d66767f8c9..33b0e5dcb976 100644 --- a/exporter/datadogexporter/example/config.yaml +++ b/exporter/datadogexporter/example/config.yaml @@ -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 From 0775893412d549ce3ae84001f9b22fb2d79b9c2e Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 22 Mar 2022 13:33:03 +0100 Subject: [PATCH 2/7] Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index faaf68319832..7d9ca0ff5332 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From f9b993effaecabfb4b95037ac87d0849c5dfbc6c Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 22 Mar 2022 13:57:00 +0100 Subject: [PATCH 3/7] [exporter/datadog] Remove Service and Version from tests --- exporter/datadogexporter/factory_test.go | 10 ---------- exporter/datadogexporter/testdata/config.yaml | 4 ---- 2 files changed, 14 deletions(-) diff --git a/exporter/datadogexporter/factory_test.go b/exporter/datadogexporter/factory_test.go index 625d582ba459..aec44b4e25d5 100644 --- a/exporter/datadogexporter/factory_test.go +++ b/exporter/datadogexporter/factory_test.go @@ -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"}, }, @@ -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")) @@ -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")) @@ -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) @@ -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{ diff --git a/exporter/datadogexporter/testdata/config.yaml b/exporter/datadogexporter/testdata/config.yaml index 928c0f9e7a36..7f561fc7260b 100644 --- a/exporter/datadogexporter/testdata/config.yaml +++ b/exporter/datadogexporter/testdata/config.yaml @@ -8,8 +8,6 @@ exporters: datadog/api: hostname: customhostname env: prod - service: myservice - version: myversion tags: - example:tag @@ -24,8 +22,6 @@ exporters: datadog/api2: hostname: customhostname env: prod - service: myservice - version: myversion tags: - example:tag From 3e40e5b904ef17a13f07a034d6529802157655a8 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 24 Mar 2022 11:12:58 +0100 Subject: [PATCH 4/7] Address review comment --- exporter/datadogexporter/factory_test.go | 74 +++++++++---------- exporter/datadogexporter/testdata/config.yaml | 4 + 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/exporter/datadogexporter/factory_test.go b/exporter/datadogexporter/factory_test.go index aec44b4e25d5..7b46ee96c387 100644 --- a/exporter/datadogexporter/factory_test.go +++ b/exporter/datadogexporter/factory_test.go @@ -127,48 +127,44 @@ 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", - EnvVarTags: "", - Tags: []string{"example:tag"}, - }, - - API: ddconfig.APIConfig{ - Key: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - Site: "datadoghq.eu", + 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", }, - - Metrics: ddconfig.MetricsConfig{ - TCPAddr: confignet.TCPAddr{ - Endpoint: "https://api.datadoghq.eu", - }, - DeltaTTL: 3600, - SendMonotonic: true, - Quantiles: true, - HistConfig: ddconfig.HistogramConfig{ - Mode: "distributions", - SendCountSum: false, - }, + DeltaTTL: 3600, + SendMonotonic: true, + Quantiles: true, + HistConfig: ddconfig.HistogramConfig{ + Mode: "distributions", + SendCountSum: false, }, - - 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()) diff --git a/exporter/datadogexporter/testdata/config.yaml b/exporter/datadogexporter/testdata/config.yaml index 7f561fc7260b..d783c7e76f94 100644 --- a/exporter/datadogexporter/testdata/config.yaml +++ b/exporter/datadogexporter/testdata/config.yaml @@ -8,6 +8,10 @@ exporters: datadog/api: hostname: customhostname env: prod + # Deprecated; kept here to avoid regressions. + service: myservice + # Deprecated; kept here to avoid regressions. + version: myversion tags: - example:tag From 14618f81735b711875a5ae4814d61f60bad07e17 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 29 Mar 2022 15:58:37 -0400 Subject: [PATCH 5/7] Fix lint --- exporter/datadogexporter/factory_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exporter/datadogexporter/factory_test.go b/exporter/datadogexporter/factory_test.go index 5691acf3be02..a59e2743a6e7 100644 --- a/exporter/datadogexporter/factory_test.go +++ b/exporter/datadogexporter/factory_test.go @@ -150,15 +150,15 @@ func TestLoadConfig(t *testing.T) { TCPAddr: confignet.TCPAddr{ Endpoint: "https://api.datadoghq.eu", }, - DeltaTTL: 3600, + DeltaTTL: 3600, SendMonotonic: true, Quantiles: true, HistConfig: ddconfig.HistogramConfig{ Mode: "distributions", SendCountSum: false, - }, + }, SumConfig: ddconfig.SumConfig{ - CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta, + CumulativeMonotonicMode: ddconfig.CumulativeMonotonicSumModeToDelta, }, }, apiConfig.Metrics) assert.Equal(t, ddconfig.TracesConfig{ From 61172089596b901a198ffbf0066ee53935301892 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Wed, 30 Mar 2022 11:33:31 -0400 Subject: [PATCH 6/7] Bump to v0.49.0 This won't make it into v0.48.0, so I updated the deprecation and removal versions --- exporter/datadogexporter/config/config.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exporter/datadogexporter/config/config.go b/exporter/datadogexporter/config/config.go index da9fa7c4a57d..6c21a20aeec7 100644 --- a/exporter/datadogexporter/config/config.go +++ b/exporter/datadogexporter/config/config.go @@ -221,14 +221,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. + // 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.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. // 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"` @@ -420,10 +420,10 @@ func (c *Config) Unmarshal(configMap *config.Map) error { 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)) + 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.51", 8783)) + c.warnings = append(c.warnings, fmt.Errorf(deprecationTemplate, "version", "v0.52.0", 8783)) } return nil From 43631e25b77594967d101b9bc2b3e99b27586e5f Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 31 Mar 2022 10:40:11 -0400 Subject: [PATCH 7/7] Update CHANGELOG --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9325fdd8a686..0543b7a3f1ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -37,8 +40,6 @@ - `datadogexporter`: Deprecate `OnlyMetadata` method from `Config` struct (#8359) - `datadogexporter`: Deprecate `GetCensoredKey` method from `APIConfig` struct (#8830) - `datadogexporter`: Deprecate `metrics::send_monotonic_counter` in favor of `metrics::sums::cumulative_monotonic_mode` (#8490) -- `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 🚀