Skip to content

Commit d6796c0

Browse files
committed
Fix OTLP env var overriding
Signed-off-by: Christopher Petito <[email protected]>
1 parent c0cc22d commit d6796c0

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

cli/command/telemetry_docker.go

+12-16
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,20 @@ func dockerExporterOTLPEndpoint(cli Cli) (endpoint string, secure bool) {
4141
otelCfg = m[otelContextFieldName]
4242
}
4343

44-
if otelCfg == nil {
45-
return "", false
44+
if otelCfg != nil {
45+
otelMap, ok := otelCfg.(map[string]any)
46+
if !ok {
47+
otel.Handle(errors.Errorf(
48+
"unexpected type for field %q: %T (expected: %T)",
49+
otelContextFieldName,
50+
otelCfg,
51+
otelMap,
52+
))
53+
}
54+
// keys from https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/
55+
endpoint, _ = otelMap[otelExporterOTLPEndpoint].(string)
4656
}
4757

48-
otelMap, ok := otelCfg.(map[string]any)
49-
if !ok {
50-
otel.Handle(errors.Errorf(
51-
"unexpected type for field %q: %T (expected: %T)",
52-
otelContextFieldName,
53-
otelCfg,
54-
otelMap,
55-
))
56-
return "", false
57-
}
58-
59-
// keys from https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/
60-
endpoint, _ = otelMap[otelExporterOTLPEndpoint].(string)
61-
6258
// Override with env var value if it exists AND IS SET
6359
// (ignore otel defaults for this override when the key exists but is empty)
6460
if override := os.Getenv(debugEnvVarPrefix + otelExporterOTLPEndpoint); override != "" {

0 commit comments

Comments
 (0)