fix(otel): normalize OTEL endpoint env vars to prevent SDK parse errors#380
Merged
ClaraTersi merged 1 commit intodevelopfrom Mar 21, 2026
Merged
Conversation
The OTEL SDK internally reads OTEL_EXPORTER_OTLP_*_ENDPOINT env vars via url.Parse(), which fails on bare "host:port" without a scheme, producing noisy "parse url" errors in the SDK's internal logger. normalizeEndpointEnvVars() runs before exporter creation and prepends "http://" to any env var missing a scheme, matching the existing normalizeEndpoint() behavior for the programmatic config path.
|
Caution Review failedPull request was closed or merged during review WalkthroughThe changes add environment variable normalization for OpenTelemetry OTLP endpoint configuration. During telemetry initialization, a new helper function processes three environment variables by trimming whitespace and prepending the HTTP scheme when endpoints lack 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
ClaraTersi
approved these changes
Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
normalizeEndpointEnvVars()that prependshttp://toOTEL_EXPORTER_OTLP_*_ENDPOINTenv vars when they contain barehost:portwithout a schemeurl.Parse()from logging noisy"parse url"errorsnormalizeEndpoint()which only handled the programmaticCollectorExporterEndpointconfig fieldProblem
The OTEL Go SDK (v1.42.0) reads endpoint env vars internally via
envconfig.WithURL()→url.Parse(). When the env var containshost:portwithout a scheme (e.g.10.10.0.202:4317), Go's URL parser fails:This happens independently of the programmatic
WithEndpoint()path, which PR #362 already fixed. The SDK reads env vars before applying programmatic options, so barehost:portin env vars still caused the error.Root Cause
The OTEL SDK's
envconfig.go(lines 93-104) usesurl.Parse()to readOTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, andOTEL_EXPORTER_OTLP_METRICS_ENDPOINT. The error appears twice per startup (once for trace exporter, once for metric exporter).Test plan
go build ./commons/opentelemetry/...passes🤖 Generated with Claude Code