-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core,node): Add instrumentation for GoogleGenerativeAI
#17625
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
Conversation
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
52f49f5
to
6ef5ce0
Compare
packages/node/src/integrations/tracing/google-genai/instrumentation.ts
Outdated
Show resolved
Hide resolved
af4e147
to
2a58c6a
Compare
dev-packages/node-integration-tests/suites/tracing/google-genai/scenario.mjs
Outdated
Show resolved
Hide resolved
packages/node/src/integrations/tracing/google-genai/instrumentation.ts
Outdated
Show resolved
Hide resolved
packages/node/src/integrations/tracing/google-genai/instrumentation.ts
Outdated
Show resolved
Hide resolved
224c1a3
to
60eb2d1
Compare
60eb2d1
to
275a9a7
Compare
tracesSampleRate: 1.0, | ||
sendDefaultPii: true, | ||
transport: loggingTransport, | ||
integrations: [Sentry.googleGenAIIntegration()], |
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.
integrations: [Sentry.googleGenAIIntegration()], |
this is added by default, right? So no need to add this here :)
tracesSampleRate: 1.0, | ||
sendDefaultPii: false, | ||
transport: loggingTransport, | ||
integrations: [Sentry.googleGenAIIntegration()], |
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.
integrations: [Sentry.googleGenAIIntegration()], |
/** | ||
* Google GenAI Integration interface for type safety | ||
*/ | ||
export interface GoogleGenAIIntegration { |
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.
do we actually need this, when we do not lookup the integration on the client anymore? :)
* @param wrappedConstructor The wrapped constructor function to replace the original with | ||
* @returns void | ||
*/ | ||
export function replaceExports( |
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 util!
exports => this._patch(exports), | ||
exports => exports, | ||
[ | ||
new InstrumentationNodeModuleFile( |
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.
let's add a comment here why this is necessary, for future reference!
const config = this.getConfig(); | ||
|
||
if (typeof Original !== 'function') { | ||
return; |
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.
return; | |
return exports; |
Do we not need to return the exports here if we do not patch it? 🤔 or is this handled if this is undefined and we do nothing then? just double checking 😅
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.
Nah i think you're correct
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.
left some small comments but overall this looks very good now 🚀
This PR implements instrumentation for the Google GenerativeAI SDK, adding automatic tracing for both direct model calls (models.generateContent) and conversational chat sessions (chats.create + sendMessage). The implementation follows Sentry's AI Agents Manual Instrumentation conventions and includes integration tests.
Usage: