traceloop / traceloop/openllmetry
๐ Bug Report: httpx and other instrumentations are not playing well with langchain instrumentation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.4k
- Forks
- 1.1k
- Avg merge
- 8d 14h
- Merged PRs (30d)
- 2
Description
Which component is this bug for?
Langchain Instrumentation
๐ Description
For example, if you also instrument httpx (which can be useful for knowing how long each actual API call took and what was the actual response from the model, such as 529 from anthropic recently), the httpx spans will appear outside of langchain spans and after them. The same problem appears if you try to create a span or interact with the current span within a custom callback -- I would expect to be within langchain span but I am not yet in any callback.
Are there any ways to reproduce that?
๐ Reproduction steps
- Take any OTEL-supporting platform (i.e. free honeycomb, free pydantic logfire, or self-hosted lgtm)
- Instrument httpx and langchain
- try invoking LLM
- See how the POST request span appears outside of langchain span
๐ Expected behavior
Any spans created within the langchain spans should be their children.
๐ Actual Behavior with Screenshots
๐ค Python Version
3.12
๐ Provide any additional context for the Bug.
No response
๐ Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
None
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 reproducing an LLM invocation with both httpx and Langchain instrumentation enabled, then inspect the resulting span nesting. Check the Langchain instrumentation and custom callback entry points mentioned in the report. Done means httpx spans and spans created in callbacks appear as children of the relevant Langchain spans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100