-
Notifications
You must be signed in to change notification settings - Fork 954
fix(langchain): ensure llm span is created #2805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
obs-gh-abhishekrao
wants to merge
24
commits into
traceloop:main
from
observeinc:abhishek/fix-langchain-propagation
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
48d1f10
fix(langchain): retain parent ctx and ensure appropriate llm span is …
obs-gh-abhishekrao 41f9ae4
Fix incorrectly coalesced attribute
obs-gh-abhishekrao c6f73c1
Fix linting issue
obs-gh-abhishekrao 3405ee5
Remove extraneous context suppression
obs-gh-abhishekrao 974261e
Fix missing attributes
obs-gh-abhishekrao ffd5825
Fix incorrectly coalesced attribute value in openai instrumentation
obs-gh-abhishekrao 7e39d7c
Add test
obs-gh-abhishekrao 5437212
Fix test flakiness from shared span context
obs-gh-abhishekrao 9483836
Match langgraph version used by sample apps
obs-gh-abhishekrao 585df14
unused imports
obs-gh-abhishekrao 3dfffe7
Inject suppression token for legacy chains
obs-gh-abhishekrao c6a5e48
Add test for langgraph ainvoke
obs-gh-abhishekrao a33806c
Fix and add test for double langgraph invoke/ainvoke
obs-gh-abhishekrao 4d8a977
Remove set_span_in_context for now
obs-gh-abhishekrao 75567ca
Lint fix
obs-gh-abhishekrao de74ec1
Fix root cause of missing LLM attributes and metrics, revert equivale…
obs-gh-abhishekrao 4267ef1
Add sample app
obs-gh-abhishekrao 5d9a48e
Propagate ctx for sync callbacks, refactor langgraph metric test
obs-gh-abhishekrao 3637178
Improve async handling of propagation and test
obs-gh-abhishekrao 1ca4d9c
Improve handling of sync context propagation
obs-gh-abhishekrao 5ce09b5
Renaming vars and adding comment for async case
obs-gh-abhishekrao 257c044
Remove unnecessary fixture from conftest
obs-gh-abhishekrao f149273
Assert against INVALID_SPAN instead of NonRecordingSpan
obs-gh-abhishekrao d4f5403
Revert unnecessary changes, add clarifying comments
obs-gh-abhishekrao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to call
attach()only in the non-async case:https://github.com/traceloop/openllmetry/pull/2805/files#diff-caff857eafc9121a585e40cdac1c0815d97f474cd3d0bf1a23755572e3b38105R448-R449
The challenge is that the Traceloop callback handler can't itself determine whether it's in an async context.
However, the
CallbackManagerexposes anis_asyncproperty, which is why the handler keeps a reference to the manager.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ronensc.
@nirga For better clarity I've added a comment to this logic. Hope it's clear.