/claim #2456
✅ PR Requirements
- I have added tests that cover my changes.
- If adding a new instrumentation or changing an existing one, I’ve added screenshots from some observability platform showing the change.
- PR name follows conventional commits format: feat(instrumentation): … or fix(instrumentation): ….
- (If applicable) I have updated the documentation accordingly.
📌 Issue Requirements
Fixes the following packages and their respective tests:
- AlephAlpha
- Anthropic
- Bedrock
- Cohere
- Google Generative AI
- Groq
- Langchain
- LlamaIndex
- Mistral AI
- Ollama
- OpenAI
- Replicate
- SageMaker
- Together
- Transformers*
- VertexAI*
- WatsonX
Additional requirements implemented:
- Maintain compatibility with the current way of emitting events, and add support for the new event-based system using official semantic conventions.
- Add a use_legacy_attributes config flag to each instrumentation (default: true). When false, events are emitted instead of legacy prompt/completion attributes.
- Add a global SDK initialization parameter use_legacy_attributes that sets the flag across all instrumentations.
✍️ Personal Notes
Initially, I tried building on top of the existing PR, but it didn’t seem to account for the nuances of each package and the code was quite hard to follow — so I ended up starting from scratch.
I’ve implemented all the required changes for the packages listed above. For testing, I modified existing tests to assert that events are not emitted when use_legacy_attributes == True, ensuring backward compatibility is maintained.
Additionally, I created two new versions of each test:
- One to verify the new event-based system is functioning as expected, including the message’s contents in the Events
- Another to verify the new event-based system is functioning as expected, without including content, following the OpenTelemetry convention and the provided example.
These changes are ready for review and merging.
⚠️ Pending Items and questions:
- VertexAI and Transformers currently don’t have tests, so I couldn’t safely implement event emission for them yet. I plan to work on these soon — do you want me to create the legacy and event tests for them as well?
- Langchain and LlamaIndex haven’t been checked yet — I’ll be reviewing them today.
- I’m having trouble implementing the new OpenAI tests when I change the instrumentations’ scope to function during testing, likely related to the _uninstrument method. I’ll post the full details on Slack.
I’ll continue working on the remaining instrumentations today and tomorrow, but the current work is ready for early review. Feedback is welcome!