feat(cloudflare,vercel-edge): Add support for OpenAI instrumentation#17338
feat(cloudflare,vercel-edge): Add support for OpenAI instrumentation#17338andreiborza merged 7 commits intodevelopfrom
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.
if you're only testing client.chat?.completions?.create you can get rid of the rest of this file.
| * 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 { |
|
is |
Yep: https://platform.openai.com/docs/libraries/typescript-javascript-library |
There was a problem hiding this comment.
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/cloudflareand@sentry/vercel-edge.To instrument the OpenAI client, wrap it with
Sentry.instrumentOpenAiClientand set recording settings.