Skip to content
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

feat(node): Add @vercel/ai instrumentation #13892

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Oct 7, 2024

Adds Sentry tracing instrumentation for the ai library.

For more information, see the ai documentation.

 const Sentry = require('@sentry/node');

 Sentry.init({
  integrations: [Sentry.vercelAIIntegration()],
 });

By default this integration adds tracing support to all ai callsites. If you need to disable
collecting spans for a specific call, you can do so by setting experimental_telemetry.isEnabled to
false in the first argument of the function call.

const result = await generateText({
  model: openai('gpt-4-turbo'),
  experimental_telemetry: { isEnabled: false },
});

If you want to collect inputs and outputs for a specific call, you must specifically opt-in to each
function call by setting experimental_telemetry.recordInputs and experimental_telemetry.recordOutputs
to true.

const result = await generateText({
 model: openai('gpt-4-turbo'),
 experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
});

resolves #13679

@AbhiPrasad AbhiPrasad self-assigned this Oct 7, 2024
Copy link
Contributor

github-actions bot commented Oct 7, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.12 KB - -
@sentry/browser - with treeshaking flags 21.82 KB - -
@sentry/browser (incl. Tracing) 35.53 KB - -
@sentry/browser (incl. Tracing, Replay) 72.44 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.81 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 76.76 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 89.22 KB - -
@sentry/browser (incl. Feedback) 39.86 KB - -
@sentry/browser (incl. sendFeedback) 27.74 KB - -
@sentry/browser (incl. FeedbackAsync) 32.54 KB - -
@sentry/react 25.79 KB - -
@sentry/react (incl. Tracing) 38.37 KB - -
@sentry/vue 27.27 KB - -
@sentry/vue (incl. Tracing) 37.33 KB - -
@sentry/svelte 23.27 KB - -
CDN Bundle 24.31 KB - -
CDN Bundle (incl. Tracing) 37.19 KB - -
CDN Bundle (incl. Tracing, Replay) 72.06 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 77.4 KB - -
CDN Bundle - uncompressed 71.42 KB - -
CDN Bundle (incl. Tracing) - uncompressed 110.47 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 223.54 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 236.76 KB - -
@sentry/nextjs (client) 38.69 KB - -
@sentry/sveltekit (client) 36.05 KB - -
@sentry/node 135.82 KB +0.57% +778 B 🔺
@sentry/node - without tracing 97.11 KB - -
@sentry/aws-serverless 109.41 KB - -

View base workflow run

@AbhiPrasad AbhiPrasad requested review from a team, Lms24 and s1gr1d and removed request for a team November 27, 2024 13:28
@AbhiPrasad AbhiPrasad marked this pull request as ready for review November 27, 2024 13:28
Copy link

codecov bot commented Nov 27, 2024

❌ 22 Tests Failed:

Tests completed Failed Passed Skipped
661 22 639 27
View the top 3 failed tests by shortest run time
transactions.test.ts Captures request metadata
Stack Traces | 0.032s run time
transactions.test.ts:139:5 Captures request metadata
transactions.test.ts Isolates requests
Stack Traces | 0.034s run time
transactions.test.ts:117:5 Isolates requests
errors.test.ts Only sends onPreResponse error to Sentry if JS error is thrown in route handler AND onPreResponse
Stack Traces | 0.041s run time
errors.test.ts:116:5 Only sends onPreResponse error to Sentry if JS error is thrown in route handler AND onPreResponse

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

Comment on lines +161 to +166
* Adds Sentry tracing instrumentation for the [ai](https://www.npmjs.com/package/ai) library.
*
* For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
*
* @example
* ```javascript
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice JS doc 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add instrumentation for ai
2 participants