-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(js): Update docs for vercelAiIntegration #14168
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ supported: | |
- javascript.express | ||
- javascript.fastify | ||
- javascript.gcp-functions | ||
- javascript.cloudflare | ||
- javascript.hapi | ||
- javascript.hono | ||
- javascript.koa | ||
|
@@ -27,22 +28,21 @@ supported: | |
|
||
<Alert> | ||
|
||
This integration only works in the Node.js and Bun runtimes. Requires SDK version `9.30.0` or higher. | ||
This integration only works in the Node.js, Cloudflare Workers, Vercel Edge Functions and Bun runtimes. Requires SDK version `9.33.0` or higher. | ||
|
||
</Alert> | ||
|
||
<PlatformSection supported={["javascript.nextjs"]}> | ||
|
||
<Include name="nextjs-server-only" /> | ||
|
||
</PlatformSection> | ||
|
||
_Import name: `Sentry.vercelAIIntegration`_ | ||
|
||
The `vercelAIIntegration` adds instrumentation for the [`ai`](https://www.npmjs.com/package/ai) SDK by Vercel to capture spans using the [`AI SDK's built-in Telemetry`](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry). Get started with the following snippet: | ||
The `vercelAIIntegration` adds instrumentation for the [`ai`](https://www.npmjs.com/package/ai) SDK by Vercel to capture spans using the [`AI SDK's built-in Telemetry`](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry). | ||
|
||
<PlatformSection notSupported={["javascript.cloudflare", "javascript.nextjs"]}> | ||
It is enabled by default and will automatically capture spans for all `ai` | ||
function calls. You can opt-in to capture inputs and outputs by setting `recordInputs` and `recordOutputs` in the integration config: | ||
|
||
```javascript | ||
Sentry.init({ | ||
dsn: "____PUBLIC_DSN____" | ||
tracesSampleRate: 1.0, | ||
integrations: [ | ||
Sentry.vercelAIIntegration({ | ||
|
@@ -53,17 +53,51 @@ Sentry.init({ | |
}); | ||
``` | ||
|
||
</PlatformSection> | ||
|
||
<PlatformSection supported={['javascript.cloudflare']}> | ||
This integration is not enabled by default. You need to manually enable it by passing `Sentry.vercelAIIntegration()` to `Sentry.init`: | ||
|
||
```javascript | ||
Sentry.init({ | ||
dsn: "____PUBLIC_DSN____" | ||
tracesSampleRate: 1.0, | ||
integrations: [Sentry.vercelAIIntegration()], | ||
}); | ||
``` | ||
|
||
</PlatformSection> | ||
|
||
<PlatformSection supported={['javascript.nextjs']}> | ||
This integration is enabled by default in the Node runtime, but not in the Edge runtime. You need to manually enable it by passing `Sentry.vercelAIIntegration()` to `Sentry.init` in your `sentry.edge.config.js` file: | ||
|
||
```javascript {filename: 'sentry.edge.config.(js|ts)'} | ||
Sentry.init({ | ||
dsn: "____PUBLIC_DSN____" | ||
tracesSampleRate: 1.0, | ||
integrations: [Sentry.vercelAIIntegration()], | ||
}); | ||
``` | ||
|
||
</PlatformSection> | ||
|
||
<PlatformSection supported={['javascript.cloudflare', 'javascript.nextjs']}> | ||
To correctly capture spans, pass the `experimental_telemetry` object with `isEnabled: true` to every `generateText`, `generateObject`, and `streamText` function call. For more details, see the [AI SDK Telemetry Metadata docs](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry#telemetry-metadata). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also call out |
||
|
||
```javascript | ||
const result = await generateText({ | ||
model: openai("gpt-4o"), | ||
experimental_telemetry: { | ||
isEnabled: true, | ||
recordInputs: true, | ||
recordOutputs: true, | ||
}, | ||
}); | ||
``` | ||
|
||
</PlatformSection> | ||
|
||
<PlatformSection notSupported={['javascript.cloudflare']}> | ||
## Options | ||
|
||
### `force` | ||
|
@@ -82,6 +116,12 @@ Sentry.init({ | |
}); | ||
``` | ||
|
||
<PlatformSection supported={["javascript.nextjs"]}> | ||
This option is not available in the Edge runtime. There, the integration is | ||
forced when it is enabled. | ||
</PlatformSection> | ||
|
||
<PlatformSection notSupported={['javascript.nextjs']}> | ||
### `recordInputs` | ||
|
||
Requires SDK version `9.27.0` or higher. | ||
|
@@ -114,6 +154,10 @@ Sentry.init({ | |
}); | ||
``` | ||
|
||
</PlatformSection> | ||
|
||
</PlatformSection> | ||
|
||
## Identifying functions | ||
|
||
In order to make it easier to correlate captured spans with the function calls we recommend setting `functionId` in `experimental_telemetry` in all generation function calls: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 can now remove

<Include name="nextjs-server-only" />
a bit earlier in this file.