open-telemetry / open-telemetry/opentelemetry-python

Honour path specified in grpc endpoint

Open
#2,579 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.