-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(cloudflare,vercel-edge): Add support for OpenAI instrumentation #17338
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
To instrument the OpenAI client, wrap it with `Sentry.instrumentOpenAiClient`. ```js import * as Sentry from '@sentry/cloudflare'; import OpenAI from 'openai'; const openai = new OpenAI(); const client = Sentry.instrumentOpenAiClient(openai, { recordInputs: true, recordOutputs: true }); // use the wrapped client ```
instrumentation directly in cloudflare/vercel-edge
cfd4bee
to
eda7807
Compare
}, | ||
}; | ||
|
||
this.responses = { |
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 you're only testing client.chat?.completions?.create
you can get rid of the rest of this file.
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.
Thanks, removed!
} | ||
|
||
/** | ||
* Instrument an OpenAI client with Sentry tracing | ||
* Can be used across Node.js, Cloudflare Workers, and Vercel Edge | ||
*/ | ||
export function instrumentOpenAiClient(client: OpenAiClient, options?: OpenAiOptions): OpenAiClient { | ||
export function instrumentOpenAiClient<T extends object>(client: T, options?: OpenAiOptions): T { |
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.
🎉
is |
Yep: https://platform.openai.com/docs/libraries/typescript-javascript-library |
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.
For now we are removing the vercel edge export until we confirm this works as intended. @andreiborza confirmed it works
Actually, tested this again and it works on vercel-edge too. |
…17338) Adds support for OpenAI manual instrumentation in `@sentry/cloudflare` and `@sentry/vercel-edge`. To instrument the OpenAI client, wrap it with `Sentry.instrumentOpenAiClient` and set recording settings. ```js import * as Sentry from '@sentry/cloudflare'; import OpenAI from 'openai'; const openai = new OpenAI(); const client = Sentry.instrumentOpenAiClient(openai, { recordInputs: true, recordOutputs: true }); // use the wrapped client ```
Adds support for OpenAI manual instrumentation in
@sentry/cloudflare
and@sentry/vercel-edge
.To instrument the OpenAI client, wrap it with
Sentry.instrumentOpenAiClient
and set recording settings.