open-telemetry / open-telemetry/opentelemetry-python-contrib
GenAI upload completion hook needs to more robust JSON encoder
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
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
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 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