From 59b9dd2f91b8118bf841c8672a61a494e2f68056 Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Mon, 16 Sep 2024 05:33:29 -0400 Subject: [PATCH] feat(datadogexporter): adds remap_metrics feature gate (#35025) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description:** Adds a metrics configuration that enables/disables the conversion of OpenTelemetry metrics to Datadog semantics in the Datadog Exporter. This conversion will soon occur in a datadog semantic processor. **Link to tracking Issue:** N/A **Testing:** Unit tests *̶*̶D̶o̶c̶u̶m̶e̶n̶t̶a̶t̶i̶o̶n̶:̶*̶*̶ O̶n̶c̶e̶ t̶h̶i̶s̶ c̶o̶n̶f̶i̶g̶u̶r̶a̶t̶i̶o̶n̶ i̶s̶ G̶A̶ w̶e̶ w̶i̶l̶l̶ u̶p̶d̶a̶t̶e̶ t̶h̶e̶ d̶o̶c̶s̶ h̶e̶r̶e̶:̶ h̶t̶t̶p̶s̶:̶//d̶o̶c̶s̶.d̶a̶t̶a̶d̶o̶g̶h̶q̶.c̶o̶m̶/o̶p̶e̶n̶t̶e̶l̶e̶m̶e̶t̶r̶y̶/c̶o̶l̶l̶e̶c̶t̶o̶r̶_̶e̶x̶p̶o̶r̶t̶e̶r̶/c̶o̶n̶f̶i̶g̶u̶r̶a̶t̶i̶o̶n̶/ --------- Co-authored-by: Yang Song Co-authored-by: Pablo Baeyens --- .chloggen/munir_add-option-to-avoid-remapping.yaml | 13 +++++++++++++ exporter/datadogexporter/factory.go | 12 ++++++++++++ exporter/datadogexporter/metrics_exporter.go | 7 ++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .chloggen/munir_add-option-to-avoid-remapping.yaml diff --git a/.chloggen/munir_add-option-to-avoid-remapping.yaml b/.chloggen/munir_add-option-to-avoid-remapping.yaml new file mode 100644 index 000000000000..35efaef6a6fd --- /dev/null +++ b/.chloggen/munir_add-option-to-avoid-remapping.yaml @@ -0,0 +1,13 @@ +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: datadogexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Adds exporter.datadogexporter.metricremappingdisabled featuregate which disables renaming OpenTelemetry metrics to match Datadog semantics. This feature gate is only for internal use." + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35025] + +# Optional: A list of users who contributed to the change. This is used to generate the list of contributors in the changelog. +change_logs: [] diff --git a/exporter/datadogexporter/factory.go b/exporter/datadogexporter/factory.go index 0a2381cda977..ec13fbbd63d0 100644 --- a/exporter/datadogexporter/factory.go +++ b/exporter/datadogexporter/factory.go @@ -53,6 +53,13 @@ var metricExportNativeClientFeatureGate = featuregate.GlobalRegistry().MustRegis featuregate.WithRegisterDescription("When enabled, metric export in datadogexporter uses native Datadog client APIs instead of Zorkian APIs."), ) +var metricRemappingDisableddFeatureGate = featuregate.GlobalRegistry().MustRegister( + "exporter.datadogexporter.metricremappingdisabled", + featuregate.StageAlpha, + featuregate.WithRegisterDescription("When enabled the Datadog Exporter remaps OpenTelemetry semantic conventions to Datadog semantic conventions. This feature gate is only for internal use."), + featuregate.WithRegisterReferenceURL("https://docs.datadoghq.com/opentelemetry/schema_semantics/metrics_mapping/"), +) + // noAPMStatsFeatureGate causes the trace consumer to skip APM stats computation. var noAPMStatsFeatureGate = featuregate.GlobalRegistry().MustRegister( "exporter.datadogexporter.DisableAPMStats", @@ -65,6 +72,11 @@ func isMetricExportV2Enabled() bool { return metricExportNativeClientFeatureGate.IsEnabled() } +// isMetricRemappingDisabled returns true if the datadogexporter should generate Datadog-compliant metrics from OpenTelemetry metrics +func isMetricRemappingDisabled() bool { + return metricRemappingDisableddFeatureGate.IsEnabled() +} + func isLogsAgentExporterEnabled() bool { return logsAgentExporterFeatureGate.IsEnabled() } diff --git a/exporter/datadogexporter/metrics_exporter.go b/exporter/datadogexporter/metrics_exporter.go index 6fa87508f40f..c6846807bd77 100644 --- a/exporter/datadogexporter/metrics_exporter.go +++ b/exporter/datadogexporter/metrics_exporter.go @@ -55,7 +55,12 @@ func translatorFromConfig(set component.TelemetrySettings, cfg *Config, attrsTra options := []otlpmetrics.TranslatorOption{ otlpmetrics.WithDeltaTTL(cfg.Metrics.DeltaTTL), otlpmetrics.WithFallbackSourceProvider(sourceProvider), - otlpmetrics.WithRemapping(), + } + + if isMetricRemappingDisabled() { + set.Logger.Warn("Metric remapping is disabled in the Datadog exporter. OpenTelemetry metrics must be mapped to Datadog semantics before metrics are exported to Datadog (ex: via a processor).") + } else { + options = append(options, otlpmetrics.WithRemapping()) } if cfg.Metrics.HistConfig.SendAggregations {