-
Notifications
You must be signed in to change notification settings - Fork 420
refactor: Updated @google/genai instrumentation to subscribe to events emitted
#3467
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
refactor: Updated @google/genai instrumentation to subscribe to events emitted
#3467
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3467 +/- ##
==========================================
- Coverage 97.80% 97.68% -0.12%
==========================================
Files 428 431 +3
Lines 56592 56773 +181
Branches 1 1
==========================================
+ Hits 55351 55461 +110
- Misses 1241 1312 +71
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e5ddbe6 to
802f0a4
Compare
bizob2828
left a comment
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.
Nice work, I had a few comments around some things. I think we can also file a ticket to abstract LLM based instrumentation to have a base LLM class to remove this copy pasta around recording messages, errors, etc but for a different story.
7dc5606 to
bb58196
Compare
|
|
a0c5b10 to
8318d26
Compare
bizob2828
left a comment
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 may have to re-check the spec for ai monitoring. Right now when the subscriber is registered it checks if ai_monitoring.enabled is set to true. If not, it will not subscribe. Any subsequent checks will never be false. This may be broken in openai as well. You should use this.config to check config, not this.agent.config. Yes they are the same thing but we're trying to create consistency.
8318d26 to
3bef21d
Compare
bizob2828
left a comment
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.
I'm going to have a lot of the same comments:
- remove optional chaining for checking configuration
- use this.enabled to check if ai monitoring is enabled
- add a this.streamingEnabled and use that to check if streaming is enabled
- We should only be checking if ai monitoring is enabled before creating LLM events, the segment should still be created
de814a2 to
94bb4bf
Compare
bizob2828
left a comment
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.
A few comments inline but also this instrumentation has created some uncovered paths that need tests:
- streaming is enabled but ai monitoring is not enabled
- streaming and ai monitoring are enabled but no active transaction
- embeddings when ai monitoring is disabled
- embeddings when ai monitoring is enabled but not in active transaction
@google/genai instrumentation to subscribe to events emitted@google/genai instrumentation to subscribe to events emitted
bizob2828
left a comment
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.
LGTM, good work on this one
This PR resolves #3441