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?
Are you willing to submit PR?
None