Skip to content
Open
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
Expand Up @@ -7,6 +7,5 @@ Sentry.init({
tracesSampleRate: 1.0,
dataCollection: { genAI: { inputs: true, outputs: true } },
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
streamGenAiSpans: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ Sentry.init({
release: '1.0',
tracesSampleRate: 1.0,
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
streamGenAiSpans: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ Sentry.init({
dataCollection: { genAI: { inputs: true, outputs: true } },
transport: loggingTransport,
traceLifecycle: 'stream',
integrations: [Sentry.vercelAIIntegration()],
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ Sentry.init({
tracesSampleRate: 1.0,
transport: loggingTransport,
traceLifecycle: 'stream',
integrations: [Sentry.vercelAIIntegration()],
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ Sentry.init({
dataCollection: { genAI: { inputs: true, outputs: true } },
transport: loggingTransport,
traceLifecycle: 'stream',
integrations: [Sentry.vercelAIIntegration()],
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ Sentry.init({
tracesSampleRate: 1.0,
transport: loggingTransport,
traceLifecycle: 'stream',
integrations: [Sentry.vercelAIIntegration()],
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ Sentry.init({
tracesSampleRate: 1.0,
dataCollection: { genAI: { inputs: true, outputs: true } },
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
streamGenAiSpans: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ Sentry.init({
release: '1.0',
tracesSampleRate: 1.0,
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
streamGenAiSpans: true,
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ Sentry.init({
tracesSampleRate: 1.0,
dataCollection: { genAI: { inputs: true, outputs: true } },
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
streamGenAiSpans: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ Sentry.init({
release: '1.0',
tracesSampleRate: 1.0,
transport: loggingTransport,
integrations: [Sentry.vercelAIIntegration()],
streamGenAiSpans: true,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as Sentry from '@sentry/node';
import { generateText } from 'ai';
import { MockLanguageModelV3 } from 'ai/test';

function makeModel(text) {
return 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 }],
warnings: [],
}),
});
}

async function run() {
// A single model instance shared by two *concurrent* generateText calls. This
// is the case where naive parent tracking could attribute a model call to the
// wrong invoke_agent span; each generate_content must land under its own
// invoke_agent, and both invoke_agents under `main`.
const sharedModel = makeModel('shared!');

await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
await Promise.all([
generateText({
experimental_telemetry: { isEnabled: true },
model: sharedModel,
prompt: 'Concurrent A?',
}),
generateText({
experimental_telemetry: { isEnabled: true },
model: sharedModel,
prompt: 'Concurrent B?',
}),
]);
});
}

run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as Sentry from '@sentry/node';
import { streamText } from 'ai';
import { MockLanguageModelV3, simulateReadableStream } from 'ai/test';

async function run() {
await Sentry.startSpan({ op: 'function', name: 'main' }, async () => {
const result = streamText({
experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
model: new MockLanguageModelV3({
doStream: async () => ({
stream: simulateReadableStream({
chunks: [
{ type: 'stream-start', warnings: [] },
{ type: 'text-start', id: '0' },
{ type: 'text-delta', id: '0', delta: 'Stream ' },
{ type: 'text-delta', id: '0', delta: 'response!' },
{ type: 'text-end', id: '0' },
{
type: 'finish',
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 },
},
},
],
}),
}),
}),
prompt: 'Stream me a response',
});

// streamText returns synchronously; drive the lazy stream to completion so
// the spans actually finish.
for await (const _part of result.fullStream) {
void _part;
}
});
}

run();
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ async function run() {
prompt: 'Where is the first span?',
});

// This span should have input and output prompts attached because telemetry is explicitly enabled.
// This span should have input and output prompts attached because recording is explicitly enabled.
// (v6 enables recording implicitly from `isEnabled: true`; v7's diagnostics channel only carries
// the explicit `recordInputs`/`recordOutputs` flags, so we set them here to exercise both.)
await generateText({
experimental_telemetry: { isEnabled: true },
experimental_telemetry: { isEnabled: true, recordInputs: true, recordOutputs: true },
model: new MockLanguageModelV3({
doGenerate: async () => ({
finishReason: { unified: 'stop', raw: 'stop' },
Expand Down
Loading
Loading