Skip to content

Commit c285d1e

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 e8f0757 commit c285d1e

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
@@ -259,10 +259,8 @@ const BUN_BUILD_NOT_TRIAGED = [
259259
'suites/tracing/mongoose-v9/test.ts',
260260
'suites/tracing/mongoose/test.ts',
261261
'suites/tracing/mysql/test.ts',
262-
'suites/tracing/openai/test.ts',
263262
'suites/tracing/prisma-orm-v8/test.ts',
264263
'suites/tracing/together-ai/test.ts',
265-
'suites/tracing/vercelai/test.ts',
266264
'suites/tracing/vercelai/v6_v7/test.ts',
267265
];
268266

‎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 { getCurrentScope, 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';
@@ -128,6 +132,19 @@ describe('init()', () => {
128132
expect(integrations?.map(({ name }) => name)).toContain('Some mock integration 4.1');
129133
expect(integrations?.map(({ name }) => name)).toContain('Some mock integration 4.3');
130134
});
135+
136+
it('adds the conversation id of the scope to gen_ai spans', () => {
137+
// The default integrations alone must do it, without the tracing integrations.
138+
mockGetTracingIntegrations.mockImplementation(() => []);
139+
init({ dsn: PUBLIC_DSN, tracesSampleRate: 1 });
140+
141+
withScope(scope => {
142+
scope.setConversationId('conversation-1');
143+
startSpan({ name: 'chat', op: 'gen_ai.chat' }, span => {
144+
expect(spanToJSON(span).attributes[GEN_AI_CONVERSATION_ID]).toBe('conversation-1');
145+
});
146+
});
147+
});
131148
});
132149

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

0 commit comments

Comments
 (0)