Repository navigation
fix(langchain): Fix missing langchain dependency for LangGraph tracing - #2988
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to c30b2fd in 1 minute and 10 seconds. Click for details.
- Reviewed
241lines of code in3files - Skipped
0files when reviewing. - Skipped posting
4draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/__init__.py:31
- Draft comment:
Changed dependency tuple now only requires 'langchain-core'. This is appropriate for LangGraph clients, but consider adding a comment or changelog note explaining why the 'langchain' dependency was dropped to avoid confusion. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% The comment is about a real change in the code - removing a dependency requirement. However, the comment is not suggesting a code change, but rather documentation. Per the rules, we should not make purely informative comments or ask for PR description updates. The code change itself appears intentional and well-structured with the new is_package_available checks. The dependency change could have significant impact on users, and documenting breaking changes is generally good practice. Maybe this deserves an exception to the documentation rule? No - the rules are clear that we should not make purely informative comments or request documentation updates. The code changes themselves properly handle the new optional dependency structure. Delete the comment since it only requests documentation and doesn't suggest any actual code changes.
2. packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/__init__.py:82
- Draft comment:
Good use of conditional wrapping: checking with is_package_available for 'langchain_community' and 'langchain_openai' ensures that instrumentation is only applied when those packages are installed. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
3. packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/utils.py:72
- Draft comment:
The utility function 'is_package_available' is concise and effective. Consider adding a brief docstring to enhance maintainability. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
4. packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py:649
- Draft comment:
Updated init_langchain_instrumentor to check for 'langchain' OR 'langgraph' is a proper fix to address LangGraph-only projects. Ensure corresponding tests cover this new condition. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%<= threshold50%The comment suggests ensuring that tests cover a new condition, which violates the rule against asking the PR author to ensure their change is tested. It doesn't provide a specific suggestion or point out a specific issue with the code.
Workflow ID: wflow_p4acY8W1ZAyxuvd6
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Collaborator
Author
|
@nirga I ran a quick benchmark on Full details in the collapsed section below Latency measurement detailsimport importlib.util
import time
import statistics
def measure_find_spec_latency(module_name, runs=100):
times = []
found = 0
for _ in range(runs):
start = time.perf_counter()
spec = importlib.util.find_spec(module_name)
end = time.perf_counter()
times.append((end - start) * 1000) # milliseconds
if spec is not None:
found += 1
print(f"find_spec('{module_name}') latency over {runs} runs:")
print(f" Avg: {statistics.mean(times):.3f} ms")
print(f" Min: {min(times):.3f} ms")
print(f" Max: {max(times):.3f} ms")
print(f" Stdev: {statistics.stdev(times):.3f} ms")
print(f" Found: {found}/{runs} times ({(found/runs)*100:.1f}%)")
if __name__ == "__main__":
# Try an available and a non-available module
measure_find_spec_latency("langgraph")
print()
measure_find_spec_latency("non_existent_package_123")$ python measure_find_spec.py
find_spec('langgraph') latency over 100 runs:
Avg: 0.070 ms
Min: 0.064 ms
Max: 0.128 ms
Stdev: 0.011 ms
Found: 100/100 times (100.0%)
find_spec('non_existent_package_123') latency over 100 runs:
Avg: 0.067 ms
Min: 0.050 ms
Max: 0.183 ms
Stdev: 0.027 ms
Found: 0/100 times (0.0%)
|
DrishyaDas
pushed a commit
to DrishyaDas/openllmetry
that referenced
this pull request
Jun 16, 2025
nina-kollman
pushed a commit
that referenced
this pull request
Aug 11, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2973
feat(instrumentation): ...orfix(instrumentation): ....Important
Fixes missing LangGraph dependency by checking for
langchainorlanggraphand conditionally wrapping functions based on package availability.langchainorlanggraphininit_langchain_instrumentor()intracing.py._wrap_openai_functions_for_tracing()in__init__.pyto conditionally wrap functions based onlangchain_communityandlangchain_openaipackage availability.is_package_available()function inutils.pyto check for package presence.langchainfrom_instrumentsin__init__.py.This description was created by
for c30b2fd. You can customize this summary. It will automatically update as commits are pushed.