open-telemetry / open-telemetry/opentelemetry-python-contrib

GenAI upload completion hook needs to more robust JSON encoder

Open
#3,803 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

gen-ai
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/ae4972c50299540bdf73c039997c7d9ced10ded1/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py#L270

In particular for tool call responses which can have arbitrary types inside of them, the uploader's JSON encoder needs to be more robust. For example, datetime may be returned from an tool.

  • Handle common datatypes like datetime.
  • Have a fallback with repr() so that the JSON doesn't get dropped on the floor
  • Log when the fallback is hit so we know to add support for more types.

It might make sense to consider pydantic for some of these edge cases (maybe as an optional dep), since many agent frameworks return a Pydantic model already that knows how to encode itself.

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 util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py around line 270 and inspect how upload JSON encoding handles tool call responses. Exercise the hook with common values such as datetime and an unsupported type; done means encoding is retained, unsupported values use repr(), and the fallback is logged.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.