open-telemetry / open-telemetry/opentelemetry-python

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

Open
#4,526 3 comments 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

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

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-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/init.py at the response handling linked in the issue. Reproduce the behavior with the telemetry.googleapis.com example_http.py instructions, then inspect how the HTTP exporter currently uses resp.text. Done means error responses are interpreted according to their content-type rather than always displayed as text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.