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
Expand Up @@ -31,34 +31,34 @@ test('should create AI spans with correct attributes', async ({ page }) => {

// First AI call - should have telemetry enabled and record inputs/outputs (sendDefaultPii: true)
/* const firstPipelineSpan = aiPipelineSpans[0];
expect(firstPipelineSpan?.data?.['ai.model.id']).toBe('mock-model-id');
expect(firstPipelineSpan?.data?.['ai.model.provider']).toBe('mock-provider');
expect(firstPipelineSpan?.data?.['ai.prompt']).toContain('Where is the first span?');
expect(firstPipelineSpan?.data?.['vercel.ai.model.id']).toBe('mock-model-id');
expect(firstPipelineSpan?.data?.['vercel.ai.model.provider']).toBe('mock-provider');
expect(firstPipelineSpan?.data?.['vercel.ai.prompt']).toContain('Where is the first span?');
expect(firstPipelineSpan?.data?.['gen_ai.response.text']).toBe('First span here!');
expect(firstPipelineSpan?.data?.['gen_ai.usage.input_tokens']).toBe(10);
expect(firstPipelineSpan?.data?.['gen_ai.usage.output_tokens']).toBe(20); */

// Second AI call - explicitly enabled telemetry
const secondPipelineSpan = aiPipelineSpans[0];
expect(secondPipelineSpan?.data?.['ai.prompt']).toContain('Where is the second span?');
expect(secondPipelineSpan?.data?.['vercel.ai.prompt']).toContain('Where is the second span?');
expect(secondPipelineSpan?.data?.['gen_ai.response.text']).toContain('Second span here!');

// Third AI call - with tool calls
/* const thirdPipelineSpan = aiPipelineSpans[2];
expect(thirdPipelineSpan?.data?.['ai.response.finishReason']).toBe('tool-calls');
expect(thirdPipelineSpan?.data?.['vercel.ai.response.finishReason']).toBe('tool-calls');
expect(thirdPipelineSpan?.data?.['gen_ai.usage.input_tokens']).toBe(15);
expect(thirdPipelineSpan?.data?.['gen_ai.usage.output_tokens']).toBe(25); */

// Tool call span
/* const toolSpan = toolCallSpans[0];
expect(toolSpan?.data?.['ai.toolCall.name']).toBe('getWeather');
expect(toolSpan?.data?.['ai.toolCall.id']).toBe('call-1');
expect(toolSpan?.data?.['ai.toolCall.args']).toContain('San Francisco');
expect(toolSpan?.data?.['ai.toolCall.result']).toContain('Sunny, 72°F'); */
expect(toolSpan?.data?.['vercel.ai.toolCall.name']).toBe('getWeather');
expect(toolSpan?.data?.['vercel.ai.toolCall.id']).toBe('call-1');
expect(toolSpan?.data?.['vercel.ai.toolCall.args']).toContain('San Francisco');
expect(toolSpan?.data?.['vercel.ai.toolCall.result']).toContain('Sunny, 72°F'); */

// Verify the fourth call was not captured (telemetry disabled)
const promptsInSpans = spans
.map(span => span.data?.['ai.prompt'])
.map(span => span.data?.['vercel.ai.prompt'])
.filter((prompt): prompt is string => prompt !== undefined);
const hasDisabledPrompt = promptsInSpans.some(prompt => prompt.includes('Where is the third span?'));
expect(hasDisabledPrompt).toBe(false);
Expand Down
Loading
Loading