opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Honour path specified in grpc endpoint

Open ElementalWarrior opened this issue 3 years ago • 0 comments

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'

ElementalWarrior avatar Mar 31 '22 14:03 ElementalWarrior