Uh oh!
There was an error while loading. Please reload this page.
feat(cloudflare,vercel-edge): Add support for OpenAI instrumentation - #17338
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
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cfd4bee to
eda7807Compare| }, | ||
| }; | ||
| 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 { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
mydea
commented
Aug 6, 2025
is |
andreiborza
commented
Aug 6, 2025
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
andreiborza
commented
Aug 6, 2025
Actually, tested this again and it works on vercel-edge too. |
Uh oh!
There was an error while loading. Please reload this page.
…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.