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
4 changes: 2 additions & 2 deletions packages/core/src/integrations/conversationId.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GEN_AI_CONVERSATION_ID } from '@sentry/conventions/attributes';
import type { Client } from '../client';
import { getCurrentScope, getIsolationScope } from '../currentScopes';
import { defineIntegration } from '../integration';
import { GEN_AI_CONVERSATION_ID_ATTRIBUTE } from '../semanticAttributes';
import type { IntegrationFn } from '../types/integration';
import type { Span } from '../types/span';
import { spanToStaticSpanJSON } from '../utils/spanUtils';
Expand Down Expand Up @@ -29,7 +29,7 @@ const _conversationIdIntegration = (() => {
return;
}

span.setAttribute(GEN_AI_CONVERSATION_ID_ATTRIBUTE, conversationId);
span.setAttribute(GEN_AI_CONVERSATION_ID, conversationId);
}
});
},
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/semanticAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,6 @@ export const SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE = 'sentry.link.type';
* The conversation ID for linking messages across API calls.
* For OpenAI Assistants API: thread_id
* For LangGraph: configurable.thread_id
* @deprecated Use `GEN_AI_CONVERSATION_ID` from `@sentry/conventions/attributes` instead.
*/
export const GEN_AI_CONVERSATION_ID_ATTRIBUTE = 'gen_ai.conversation.id';
20 changes: 10 additions & 10 deletions packages/core/test/lib/integrations/conversationId.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GEN_AI_CONVERSATION_ID } from '@sentry/conventions/attributes';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { getCurrentScope, getIsolationScope, setCurrentClient, startSpan } from '../../../src';
import { conversationIdIntegration } from '../../../src/integrations/conversationId';
import { GEN_AI_CONVERSATION_ID_ATTRIBUTE } from '../../../src/semanticAttributes';
import { spanToStaticSpanJSON } from '../../../src/utils/spanUtils';
import { getDefaultTestClientOptions, TestClient } from '../../mocks/client';

Expand All @@ -28,7 +28,7 @@ describe('ConversationId', () => {

startSpan({ name: 'test-span', op: 'gen_ai.chat' }, span => {
const spanJSON = spanToStaticSpanJSON(span);
expect(spanJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBe('conv_test_123');
expect(spanJSON.data[GEN_AI_CONVERSATION_ID]).toBe('conv_test_123');
});
});

Expand All @@ -37,7 +37,7 @@ describe('ConversationId', () => {

startSpan({ name: 'test-span', op: 'gen_ai.chat' }, span => {
const spanJSON = spanToStaticSpanJSON(span);
expect(spanJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBe('conv_isolation_456');
expect(spanJSON.data[GEN_AI_CONVERSATION_ID]).toBe('conv_isolation_456');
});
});

Expand All @@ -47,14 +47,14 @@ describe('ConversationId', () => {

startSpan({ name: 'test-span', op: 'gen_ai.chat' }, span => {
const spanJSON = spanToStaticSpanJSON(span);
expect(spanJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBe('conv_current_789');
expect(spanJSON.data[GEN_AI_CONVERSATION_ID]).toBe('conv_current_789');
});
});

it('does not apply conversation ID when not set in scope', () => {
startSpan({ name: 'test-span', op: 'gen_ai.chat' }, span => {
const spanJSON = spanToStaticSpanJSON(span);
expect(spanJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBeUndefined();
expect(spanJSON.data[GEN_AI_CONVERSATION_ID]).toBeUndefined();
});
});

Expand All @@ -64,7 +64,7 @@ describe('ConversationId', () => {

startSpan({ name: 'test-span', op: 'gen_ai.chat' }, span => {
const spanJSON = spanToStaticSpanJSON(span);
expect(spanJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBeUndefined();
expect(spanJSON.data[GEN_AI_CONVERSATION_ID]).toBeUndefined();
});
});

Expand All @@ -74,7 +74,7 @@ describe('ConversationId', () => {
startSpan({ name: 'parent-span', op: 'gen_ai.invoke_agent' }, () => {
startSpan({ name: 'child-span', op: 'gen_ai.chat' }, childSpan => {
const childJSON = spanToStaticSpanJSON(childSpan);
expect(childJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBe('conv_nested_abc');
expect(childJSON.data[GEN_AI_CONVERSATION_ID]).toBe('conv_nested_abc');
});
});
});
Expand All @@ -87,12 +87,12 @@ describe('ConversationId', () => {
name: 'test-span',
op: 'gen_ai.chat',
attributes: {
[GEN_AI_CONVERSATION_ID_ATTRIBUTE]: 'conv_explicit',
[GEN_AI_CONVERSATION_ID]: 'conv_explicit',
},
},
span => {
const spanJSON = spanToStaticSpanJSON(span);
expect(spanJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBe('conv_from_scope');
expect(spanJSON.data[GEN_AI_CONVERSATION_ID]).toBe('conv_from_scope');
},
);
});
Expand All @@ -102,7 +102,7 @@ describe('ConversationId', () => {

startSpan({ name: 'db-query', op: 'db.query' }, span => {
const spanJSON = spanToStaticSpanJSON(span);
expect(spanJSON.data[GEN_AI_CONVERSATION_ID_ATTRIBUTE]).toBeUndefined();
expect(spanJSON.data[GEN_AI_CONVERSATION_ID]).toBeUndefined();
});
});
});
Loading