Skip to content

🐛 Bug Report: httpx and other instrumentations are not playing well with langchain instrumentation #3214

@zmievsa

Description

@zmievsa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions