Skip to content
Draft
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 @@ -46,6 +46,17 @@ export default {
});
return Response.json({ traceId: spanContext?.traceId });
}
case '/test-workers-ai-clairic': {
await env.AI.run('@cf/cloudflare/clairic', {
model: 'clairic',
state: 'Invoice INV-2291 from Northwind Supply. Total due: $1,080.00.',
fields: {
invoice_number: { type: 'text' },
total: { type: 'number', decimals: 2, unit: 'USD', instructions: 'Amount due' },
},
});
return Response.json({ traceId: spanContext?.traceId });
}
case '/test-span':
return Response.json({ spanId: spanContext?.spanId, traceId: spanContext?.traceId });
case '/test-workflow-sleep': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,26 @@ test('Sends a Workers AI gen_ai.decide span for a Clef call to Sentry', async ()
'gen_ai.output.messages': expect.stringContaining('"urgent"'),
});
});

test('Sends a Workers AI gen_ai.extract span for a Clairic call to Sentry', async () => {
const { traceId }: { traceId: string } = JSON.parse(
await fetchFromWorker(`${workerUrl}/test-workers-ai-clairic`, 200),
);

console.log(`Polling for gen_ai.extract span: sentry trace view ${traceTarget(traceId)}`);

let spanId: string | undefined;
await expect
.poll(() => (spanId = findSpanInTrace(traceId, 'gen_ai.extract')?.event_id), EVENT_POLLING_OPTIONS)
.toBeDefined();

await expect
.poll(() => fetchSpanAttributes(traceId, spanId!), EVENT_POLLING_OPTIONS)
.toMatchObject({
'gen_ai.operation.name': 'extract',
'gen_ai.request.model': '@cf/cloudflare/clairic',
'gen_ai.response.model': expect.stringContaining('clairic'),
'gen_ai.input.messages': expect.stringContaining('Northwind Supply'),
'gen_ai.output.messages': expect.stringContaining('INV-2291'),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

E2E test uses hardcoded attribute names

Low Severity

The new Clairic E2E assertions hard-code span attribute keys such as gen_ai.operation.name, gen_ai.request.model, gen_ai.response.model, gen_ai.input.messages, and gen_ai.output.messages. Testing conventions require those keys to come from @sentry/conventions constants rather than string literals.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 4b85e32. Configure here.

});
Loading