Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
tracesSampleRate: 1.0,
sendDefaultPii: true,
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
Copy link
Member

Choose a reason for hiding this comment

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

just a question: is there any specific reason we set this here?

Copy link
Member Author

@RulaKhaled RulaKhaled Jan 9, 2026

Choose a reason for hiding this comment

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

not that i know of, this is just copied from v5

tracesSampleRate: 1.0,
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as Sentry from '@sentry/node';
import { generateText, tool } from 'ai';
import { MockLanguageModelV3 } from 'ai/test';
import { z } from 'zod';

async function run() {
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
await generateText({
model: new MockLanguageModelV3({
doGenerate: async () => ({
finishReason: { unified: 'tool-calls', raw: 'tool_calls' },
usage: {
inputTokens: { total: 15, noCache: 15, cached: 0 },
outputTokens: { total: 25, noCache: 25, cached: 0 },
totalTokens: { total: 40, noCache: 40, cached: 0 },
},
content: [
{
type: 'tool-call',
toolCallId: 'call-1',
toolName: 'getWeather',
input: JSON.stringify({ location: 'San Francisco' }),
},
],
warnings: [],
}),
}),
tools: {
getWeather: tool({
inputSchema: z.object({ location: z.string() }),
execute: async () => {
throw new Error('Error in tool');
},
}),
},
prompt: 'What is the weather in San Francisco?',
});
});
}

run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import * as Sentry from '@sentry/node';
import { generateText, tool } from 'ai';
import { MockLanguageModelV3 } from 'ai/test';
import { z } from 'zod';

async function run() {
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
await generateText({
model: new MockLanguageModelV3({
doGenerate: async () => ({
finishReason: { unified: 'stop', raw: 'stop' },
usage: {
inputTokens: { total: 10, noCache: 10, cached: 0 },
outputTokens: { total: 20, noCache: 20, cached: 0 },
totalTokens: { total: 30, noCache: 30, cached: 0 },
},
content: [{ type: 'text', text: 'First span here!' }],
warnings: [],
}),
}),
prompt: 'Where is the first span?',
});

// This span should have input and output prompts attached because telemetry is explicitly enabled.
await generateText({
experimental_telemetry: { isEnabled: true },
model: new MockLanguageModelV3({
doGenerate: async () => ({
finishReason: { unified: 'stop', raw: 'stop' },
usage: {
inputTokens: { total: 10, noCache: 10, cached: 0 },
outputTokens: { total: 20, noCache: 20, cached: 0 },
totalTokens: { total: 30, noCache: 30, cached: 0 },
},
content: [{ type: 'text', text: 'Second span here!' }],
warnings: [],
}),
}),
prompt: 'Where is the second span?',
});

// This span should include tool calls and tool results
await generateText({
model: new MockLanguageModelV3({
doGenerate: async () => ({
finishReason: { unified: 'tool-calls', raw: 'tool_calls' },
usage: {
inputTokens: { total: 15, noCache: 15, cached: 0 },
outputTokens: { total: 25, noCache: 25, cached: 0 },
totalTokens: { total: 40, noCache: 40, cached: 0 },
},
content: [
{
type: 'tool-call',
toolCallId: 'call-1',
toolName: 'getWeather',
input: JSON.stringify({ location: 'San Francisco' }),
},
],
warnings: [],
}),
}),
tools: {
getWeather: tool({
inputSchema: z.object({ location: z.string() }),
execute: async ({ location }) => `Weather in ${location}: Sunny, 72°F`,
}),
},
prompt: 'What is the weather in San Francisco?',
});

// This span should not be captured because we've disabled telemetry
await generateText({
experimental_telemetry: { isEnabled: false },
model: new MockLanguageModelV3({
doGenerate: async () => ({
finishReason: { unified: 'stop', raw: 'stop' },
usage: {
inputTokens: { total: 10, noCache: 10, cached: 0 },
outputTokens: { total: 20, noCache: 20, cached: 0 },
totalTokens: { total: 30, noCache: 30, cached: 0 },
},
content: [{ type: 'text', text: 'Third span here!' }],
warnings: [],
}),
}),
prompt: 'Where is the third span?',
});
});
}

run();
Loading
Loading