traceloop / traceloop/openllmetry

๐Ÿ› Bug Report: httpx and other instrumentations are not playing well with langchain instrumentation

Open
#3,214 2 comments 0 reactions 0 assignees View on GitHub

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
Image
๐Ÿค– 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.