Skip to content

fix(otlptracehttp): keep traces endpoint URL trailing slashes #6710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mjq
Copy link

@mjq mjq commented Apr 29, 2025

When setting an explicit OTLP traces endpoint URL (via otlptracehttp.WithEndpointURL or the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT environment variable), any given trailing slash is stripped. This makes it impossible to export traces to an endpoint requiring a trailing slash. It also conflicts with the spec:

For the per-signal variables (OTEL_EXPORTER_OTLP_<signal>_ENDPOINT), the URL MUST be used as-is without any modification. The only exception is that if an URL contains no path part, the root path / MUST be used (see Example 2).

This stripping happens due to the use of path.Clean in otlpconfig.cleanPath. From the path.Clean docs:

The returned path ends in a slash only if it is the root "/".

Other signals appear to use path.Clean and might therefore have the same bug, but I've only tested and fixed traces.

Fixes #6709.

@mjq mjq changed the title Ffix(otlptracehttp): keep traces endpoint URL trailing slashes fix(otlptracehttp): keep traces endpoint URL trailing slashes Apr 29, 2025
@dmathieu
Copy link
Member

the URL MUST be used as-is without any modification

This kind of indicates we should remove path.Clean entirely.

@pellared
Copy link
Member

@mjq, ping 😉

See: #6710 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trailing slashes are stripped from trace endpoint URLs
3 participants