Skip to content

Commit 581f33e

Browse files
bramweltclaude
andcommitted
Remove os.Setenv from endpoint normalization
WithEndpointURL receives the normalized endpoint explicitly, making the env var mutation unnecessary. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Issue: LFXV2-612 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
1 parent cec170e commit 581f33e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/utils/otel.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,11 @@ func SetupOTelSDKWithConfig(ctx context.Context, cfg OTelConfig) (shutdown func(
188188
err = errors.Join(inErr, shutdown(ctx))
189189
}
190190

191-
// Normalize endpoint to include a URL scheme so the SDK can parse it.
192-
// The SDK reads OTEL_EXPORTER_OTLP_ENDPOINT internally; updating the
193-
// env var prevents it from logging a parse error for bare IP:port values.
191+
// Normalize endpoint to include a URL scheme so WithEndpointURL can
192+
// parse it. Bare IP:port values like "127.0.0.1:4317" cause url.Parse
193+
// to fail with "first path segment in URL cannot contain colon".
194194
if cfg.Endpoint != "" {
195195
cfg.Endpoint = endpointURL(cfg.Endpoint, cfg.Insecure)
196-
os.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", cfg.Endpoint)
197196
}
198197

199198
// Create resource with service information.

0 commit comments

Comments
 (0)