-
Notifications
You must be signed in to change notification settings - Fork 423
refactor: Update @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
base: main
Are you sure you want to change the base?
refactor: Update @google/genai instrumentation to subscribe to events emitted
#3467
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3467 +/- ##
===========================================
+ Coverage 81.46% 97.64% +16.17%
===========================================
Files 409 424 +15
Lines 54383 55846 +1463
Branches 1 1
===========================================
+ Hits 44305 54532 +10227
+ Misses 10078 1314 -8764
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.
| } | ||
| } | ||
| return result | ||
| }.bind(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.
you could just save off this references as const self = this and use self.<fn> within the wrapped stream
7dc5606 to
bb58196
Compare
| } | ||
|
|
||
| handler(data, ctx) { | ||
| if (!this.agent?.config?.ai_monitoring?.enabled) { |
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.
| if (!this.agent?.config?.ai_monitoring?.enabled) { | |
| if (!this?.config?.ai_monitoring?.enabled) { |
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 confused why is this being checked? It's build into the google gen ai base handler?
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.
OIC, this is because you can dynamically set this config after start up. I missed that when porting over openai. We should clean this up to reduce redundancy though but we can handle that in the AIM subscriber abstraction. Can you make sure you file that ticket?
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.
Yes I was planning on making the ticket shortly
|
|
87a0b88 to
a0c5b10
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.
This PR resolves #3441