Skip to content

Commit 84bccb6

Browse files
JPeer264claude
andcommitted
fix(bun): Add conversationIdIntegration to the default integrations
`@sentry/bun` builds its own list of default integrations, and it did not include `conversationIdIntegration`, which every other server SDK installs. So on Bun, a conversation id set on the scope never reached the gen_ai spans. This was the only reason the bundled Bun runs of the OpenAI and Vercel AI (v4) suites failed, so both run again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 38396de commit 84bccb6

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎dev-packages/bun-integration-tests/node-suites/excludes.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,8 @@ const BUN_BUILD_NOT_TRIAGED = [
258258
'suites/tracing/mongoose-v9/test.ts',
259259
'suites/tracing/mongoose/test.ts',
260260
'suites/tracing/mysql/test.ts',
261-
'suites/tracing/openai/test.ts',
262261
'suites/tracing/prisma-orm-v8/test.ts',
263262
'suites/tracing/together-ai/test.ts',
264-
'suites/tracing/vercelai/test.ts',
265263
'suites/tracing/vercelai/v6_v7/test.ts',
266264
];
267265

‎packages/bun/src/sdk.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as os from 'node:os';
22
import type { Integration, Options } from '@sentry/core';
33
import {
44
applySdkMetadata,
5+
conversationIdIntegration,
56
dedupeIntegration,
67
eventFiltersIntegration,
78
functionToStringIntegration,
@@ -51,6 +52,7 @@ export function getDefaultIntegrationsWithoutPerformance(): Integration[] {
5152
linkedErrorsIntegration(),
5253
dedupeIntegration(),
5354
requestDataIntegration(),
55+
conversationIdIntegration(),
5456
// Native Wrappers
5557
consoleIntegration(),
5658
httpIntegration(),

‎packages/bun/test/init.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GEN_AI_CONVERSATION_ID } from '@sentry/conventions/attributes';
12
import { type Integration } from '@sentry/core';
23
import * as sentryServerUtils from '@sentry/server-utils';
34
import type { Mock } from 'bun:test';
@@ -8,6 +9,9 @@ import {
89
getDefaultIntegrationsWithoutPerformance,
910
init,
1011
initWithoutDefaultIntegrations,
12+
spanToJSON,
13+
startSpan,
14+
withScope,
1115
} from '../src';
1216

1317
const PUBLIC_DSN = 'https://username@domain/123';
@@ -127,6 +131,19 @@ describe('init()', () => {
127131
expect(integrations?.map(({ name }) => name)).toContain('Some mock integration 4.1');
128132
expect(integrations?.map(({ name }) => name)).toContain('Some mock integration 4.3');
129133
});
134+
135+
it('adds the conversation id of the scope to gen_ai spans', () => {
136+
// The default integrations alone must do it, without the tracing integrations.
137+
mockGetTracingIntegrations.mockImplementation(() => []);
138+
init({ dsn: PUBLIC_DSN, tracesSampleRate: 1 });
139+
140+
withScope(scope => {
141+
scope.setConversationId('conversation-1');
142+
startSpan({ name: 'chat', op: 'gen_ai.chat' }, span => {
143+
expect(spanToJSON(span).attributes[GEN_AI_CONVERSATION_ID]).toBe('conversation-1');
144+
});
145+
});
146+
});
130147
});
131148

132149
describe('runtime', () => {

0 commit comments

Comments
 (0)