open-telemetry / open-telemetry/opentelemetry-python
Honour path specified in grpc endpoint
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
Describe your environment
Python behind nginx+uwsgi. Grpc endpoint behind AWS ALB with prefixed path for listener rule.
The issue has not been fixed on main:
https://github.com/open-telemetry/opentelemetry-python/blob/main/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/exporter.py#L235
netloc does not include path.
This also seems to break the opentelemetry specification:
Endpoint (OTLP/HTTP): Target URL to which the exporter is going to send spans or metrics. The endpoint MUST be a valid URL with scheme (http or https) and host, MAY contain a port, SHOULD contain a path and MUST NOT contain other parts
https://github.com/open-telemetry/opentelemetry-specification/blob/70fecd2dcba505b3ac3a7cb1851f947047743d24/specification/protocol/exporter.md
Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.
Configure otlp grpc exporter with OTEL_EXPORTER_OTLP_ENDPOINT environment variable. Host grpc endpoint behind a url path.
What is the expected behavior?
The endpoint used includes the path and port, not just the domain.
What is the actual behavior?
Only the hostname is used
Additional context
>>> from urllib.parse import urlparse
>>> url = urlparse("https://sub.example.com:1234/some_prefix/grpc")
>>> url.netloc
'sub.example.com:1234'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/exporter.py around line 235, then reproduce the configuration with OTEL_EXPORTER_OTLP_ENDPOINT and a prefixed path. Done means the grpc endpoint uses the configured path and port as well as the hostname.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, grpc, nginx, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100