From 755bb87d36f9de47deeeda772943f02f6810f214 Mon Sep 17 00:00:00 2001 From: Ayan Khan Date: Tue, 25 Jun 2024 15:50:40 -0400 Subject: [PATCH 1/3] update otel env telemetry metric tag naming --- ddtrace/tracer/otel_dd_mappings.go | 6 ++++-- ddtrace/tracer/otel_dd_mappings_test.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ddtrace/tracer/otel_dd_mappings.go b/ddtrace/tracer/otel_dd_mappings.go index 9af9b9478d..576cac8c6d 100644 --- a/ddtrace/tracer/otel_dd_mappings.go +++ b/ddtrace/tracer/otel_dd_mappings.go @@ -89,14 +89,16 @@ func getDDorOtelConfig(configName string) string { val := os.Getenv(config.dd) if otVal := os.Getenv(config.ot); otVal != "" { + ddVarPrefix := "config.datadog:" + otelVarPrefix := "config.opentelemetry:" if val != "" { log.Warn("Both %v and %v are set, using %v=%v", config.ot, config.dd, config.dd, val) - telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.hiding", 1.0, []string{config.dd, config.ot}, true) + telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.hiding", 1.0, []string{ddVarPrefix + config.dd, otelVarPrefix + config.ot}, true) } else { v, err := config.remapper(otVal) if err != nil { log.Warn(err.Error()) - telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.invalid", 1.0, []string{config.dd, config.ot}, true) + telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.invalid", 1.0, []string{ddVarPrefix + config.dd, otelVarPrefix + config.ot}, true) } val = v } diff --git a/ddtrace/tracer/otel_dd_mappings_test.go b/ddtrace/tracer/otel_dd_mappings_test.go index 8cbaa3318f..1ecfb75149 100644 --- a/ddtrace/tracer/otel_dd_mappings_test.go +++ b/ddtrace/tracer/otel_dd_mappings_test.go @@ -36,7 +36,7 @@ func TestAssessSource(t *testing.T) { t.Setenv("OTEL_SERVICE_NAME", "123") v := getDDorOtelConfig("service") assert.Equal(t, "abc", v) - telemetryClient.AssertCalled(t, "Count", telemetry.NamespaceTracers, "otel.env.hiding", 1.0, []string{"DD_SERVICE", "OTEL_SERVICE_NAME"}, true) + telemetryClient.AssertCalled(t, "Count", telemetry.NamespaceTracers, "otel.env.hiding", 1.0, []string{"config.datadog:DD_SERVICE", "config.opentelemetry:OTEL_SERVICE_NAME"}, true) }) t.Run("invalid-ot", func(t *testing.T) { telemetryClient := new(telemetrytest.MockClient) @@ -44,6 +44,6 @@ func TestAssessSource(t *testing.T) { t.Setenv("OTEL_LOG_LEVEL", "nonesense") v := getDDorOtelConfig("debugMode") assert.Equal(t, "", v) - telemetryClient.AssertCalled(t, "Count", telemetry.NamespaceTracers, "otel.env.invalid", 1.0, []string{"DD_TRACE_DEBUG", "OTEL_LOG_LEVEL"}, true) + telemetryClient.AssertCalled(t, "Count", telemetry.NamespaceTracers, "otel.env.invalid", 1.0, []string{"config.datadog:DD_TRACE_DEBUG", "config.opentelemetry:OTEL_LOG_LEVEL"}, true) }) } From 9c8d662dbd144ca8372b46fc5cc2df7871252000 Mon Sep 17 00:00:00 2001 From: Ayan Khan Date: Thu, 27 Jun 2024 10:48:08 -0400 Subject: [PATCH 2/3] Update ddtrace/tracer/otel_dd_mappings.go Co-authored-by: Diana Shevchenko <40775148+dianashevchenko@users.noreply.github.com> --- ddtrace/tracer/otel_dd_mappings.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/otel_dd_mappings.go b/ddtrace/tracer/otel_dd_mappings.go index 576cac8c6d..9298514eca 100644 --- a/ddtrace/tracer/otel_dd_mappings.go +++ b/ddtrace/tracer/otel_dd_mappings.go @@ -89,8 +89,8 @@ func getDDorOtelConfig(configName string) string { val := os.Getenv(config.dd) if otVal := os.Getenv(config.ot); otVal != "" { - ddVarPrefix := "config.datadog:" - otelVarPrefix := "config.opentelemetry:" + ddPrefix := "config.datadog:" + otelPrefix := "config.opentelemetry:" if val != "" { log.Warn("Both %v and %v are set, using %v=%v", config.ot, config.dd, config.dd, val) telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.hiding", 1.0, []string{ddVarPrefix + config.dd, otelVarPrefix + config.ot}, true) From 04e1195ee7ac1b6e9c8ce3d956d6367e43a12712 Mon Sep 17 00:00:00 2001 From: Ayan Khan Date: Thu, 27 Jun 2024 10:50:49 -0400 Subject: [PATCH 3/3] fix --- ddtrace/tracer/otel_dd_mappings.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddtrace/tracer/otel_dd_mappings.go b/ddtrace/tracer/otel_dd_mappings.go index 9298514eca..4800c2e480 100644 --- a/ddtrace/tracer/otel_dd_mappings.go +++ b/ddtrace/tracer/otel_dd_mappings.go @@ -93,12 +93,12 @@ func getDDorOtelConfig(configName string) string { otelPrefix := "config.opentelemetry:" if val != "" { log.Warn("Both %v and %v are set, using %v=%v", config.ot, config.dd, config.dd, val) - telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.hiding", 1.0, []string{ddVarPrefix + config.dd, otelVarPrefix + config.ot}, true) + telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.hiding", 1.0, []string{ddPrefix + config.dd, otelPrefix + config.ot}, true) } else { v, err := config.remapper(otVal) if err != nil { log.Warn(err.Error()) - telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.invalid", 1.0, []string{ddVarPrefix + config.dd, otelVarPrefix + config.ot}, true) + telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.invalid", 1.0, []string{ddPrefix + config.dd, otelPrefix + config.ot}, true) } val = v }