Skip to content

Commit

Permalink
Updates the expected telemetry tags for OTel env-var mapping in line …
Browse files Browse the repository at this point in the history
…with the latest RFC

  config.datadog       -> config_datadog
  config.opentelemetry -> config_opentelemetry

The expected tag values should also be lower-case.
  • Loading branch information
mcculls committed Jul 25, 2024
1 parent 05a8b5a commit 91a7e8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions ddtrace/tracer/otel_dd_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,18 @@ func getDDorOtelConfig(configName string) string {

val := os.Getenv(config.dd)
if otVal := os.Getenv(config.ot); otVal != "" {
ddPrefix := "config.datadog:"
otelPrefix := "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{ddPrefix + config.dd, otelPrefix + config.ot}, true)
telemetryTags = []string{ddPrefix + strings.ToLower(config.dd), otelPrefix + strings.ToLower(config.ot)}

Check failure on line 96 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / go get -u smoke test

undefined: telemetryTags

Check failure on line 96 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags

Check failure on line 96 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags

Check failure on line 96 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags
telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.hiding", 1.0, telemetryTags, true)

Check failure on line 97 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / go get -u smoke test

undefined: telemetryTags

Check failure on line 97 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags

Check failure on line 97 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags

Check failure on line 97 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags
} else {
v, err := config.remapper(otVal)
if err != nil {
log.Warn(err.Error())
telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.invalid", 1.0, []string{ddPrefix + config.dd, otelPrefix + config.ot}, true)
telemetryTags = []string{ddPrefix + strings.ToLower(config.dd), otelPrefix + strings.ToLower(config.ot)}

Check failure on line 102 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / go get -u smoke test

undefined: telemetryTags

Check failure on line 102 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags

Check failure on line 102 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags
telemetry.GlobalClient.Count(telemetry.NamespaceTracers, "otel.env.invalid", 1.0, telemetryTags, true)

Check failure on line 103 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / go get -u smoke test

undefined: telemetryTags

Check failure on line 103 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags

Check failure on line 103 in ddtrace/tracer/otel_dd_mappings.go

View workflow job for this annotation

GitHub Actions / PR Unit and Integration Tests / test-core

undefined: telemetryTags
}
val = v
}
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/tracer/otel_dd_mappings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ 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{"config.datadog:DD_SERVICE", "config.opentelemetry: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)
defer telemetry.MockGlobalClient(telemetryClient)()
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{"config.datadog:DD_TRACE_DEBUG", "config.opentelemetry: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)
})
}

0 comments on commit 91a7e8c

Please sign in to comment.