open-telemetry / open-telemetry/opentelemetry-python
OLTP Span Exporter isn't compatible with HTTP 2 OLTP endpoints
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
I'm trying to use the OLTP Span exporter for metrics and traces to export to an OLTP endpoint.
This endpoint supports HTTP/2, per the spec OLTP endpoints can support both HTTP/2 and HTTP/1.1 https://opentelemetry.io/docs/specs/otlp/#otlphttp and if they do, they should fall back to HTTP/1.1.
This is my configuration code.
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry import metrics
from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
def configure_oltp_tracing(service_name: str = "demo", endpoint: str = "http://localhost:4317"):
# Service name is required for most backends
resource = Resource(attributes={
SERVICE_NAME: service_name
})
traceProvider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint=f"{endpoint}/v1/traces"))
traceProvider.add_span_processor(processor)
trace.set_tracer_provider(traceProvider)
reader = PeriodicExportingMetricReader(
OTLPMetricExporter(endpoint=f"{endpoint}/v1/metrics")
)
meterProvider = MeterProvider(resource=resource, metric_readers=[reader])
metrics.set_meter_provider(meterProvider)
I get the following error when traces are exported (and same for metrics)
ERROR:opentelemetry.exporter.otlp.proto.http.trace_exporter:Failed to export batch code: 400, reason: An HTTP/1.x request was sent to an HTTP/2 only endpoint.
The OLTP Exporters for Python are using the requests package, which doesn't support HTTP/2 at all and likely never will since it's only security patches being applied to it nowadays.
Going forward, this package needs to switch to a different HTTP library like httpx to support HTTP/2.
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 by reviewing the Python OTLP HTTP trace and metric exporters and their current use of requests, then compare the transport requirements in the OTLP HTTP specification with an HTTP/2-capable client. Done means both exporters work with HTTP/2 OTLP endpoints while preserving HTTP/1.1 compatibility, with validation for trace and metric export.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100