-
Notifications
You must be signed in to change notification settings - Fork 1
update Python implementation to match JS #9
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
base: main
Are you sure you want to change the base?
Conversation
ported updated version from the ADOT repo changed formatting, changed some variable and class names, etc. 1 small bug fix in init.py (added back removal of handlers) changed logic for grabbing names in llm start and chatmodel start
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.
Pull Request Overview
This PR updates the Python implementation to match the JavaScript implementation for LangChain v2 instrumentation. The changes modify how initial attributes are handled in ChatModelStart and LLMStart events and rename spans to use API names instead of model names.
- Refactored attribute extraction into separate functions for serialized and metadata parameters
- Modified span naming to use API names rather than model names to match JS implementation
- Added stop sequences attribute support and fixed handler removal bug
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| span_attributes.py | Renamed class from Span_Attributes to SpanAttributes and added GEN_AI_REQUEST_STOP_SEQUENCES attribute |
| callback_handler.py | Refactored parameter extraction into separate functions, updated span naming logic, and fixed attribute references |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/opentelemetry/instrumentation/langchain_v2/callback_handler.py
Outdated
Show resolved
Hide resolved
|
|
||
|
|
||
| def _set_request_params_serialized(span, serialized, span_holder: SpanHolder): | ||
| if serialized and serialized["kwargs"]: |
Copilot
AI
Aug 21, 2025
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.
This code will raise a KeyError if 'kwargs' key doesn't exist in serialized dict. Should use serialized.get("kwargs") instead.
| if serialized and serialized["kwargs"]: | |
| if serialized and serialized.get("kwargs"): |
src/opentelemetry/instrumentation/langchain_v2/callback_handler.py
Outdated
Show resolved
Hide resolved
|
I don't think we should go against the semantic conventions to align with JS. Was there a reason we didn't align with semantic conventions in JS? |
|
LGTM |
…tests, the other tests that require vcr or cassettes are there for reference so I am not deleting them for the time being and am leaving them in this repo
Modified how we grab initial attributes in ChatModelStart and LLMStart
IMPORTANT CHANGES:
chat and llm start spans are now named after the API we use ('chat ChatBedrock' or 'chat BedrockLLM' for example) rather than the model used.