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

OTLP HTTP Exporter Should Parse response based on content-type header

Open DylanRussell opened this issue 8 months ago • 0 comments

Describe your environment

OS: Linux Python version: 3.12 SDK version: 1.24 API version: 1.24

What happened?

Check out https://github.com/open-telemetry/opentelemetry-proto/issues/640

The response from the HTTP OTLP Exporters should be parsed based on the content-type header in the response.

Currently it prints out resp.text

But that mangles things a bit if the response is proto encoded.

I think the response can also be in json ?

For reference here is how the collector parses proto

Steps to Reproduce

Follow the instructions to call telemetry.googleapis.com here: https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/tree/main/samples/otlptrace via python3 example_http.py. Be sure to skip the step setting the environment variables export OTEL_RESOURCE_ATTRIBUTES="gcp.project_id=<project-id>".

You will see an error returned that looks a bit weird because it is proto encoded, but it is just printed as text.

Expected Result

Expect error response to be parsed based on content-type encoding

Actual Result

Error response always parsed as text

Additional context

No response

Would you like to implement a fix?

None

DylanRussell avatar Apr 02 '25 16:04 DylanRussell