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
32 changes: 16 additions & 16 deletions dev-packages/node-integration-tests/suites/tracing/openai/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe('OpenAI integration', () => {
// Second span - responses API
expect.objectContaining({
data: {
'gen_ai.operation.name': 'chat',
'sentry.op': 'gen_ai.chat',
'gen_ai.operation.name': 'responses',
'sentry.op': 'gen_ai.responses',
'sentry.origin': 'manual',
'gen_ai.system': 'openai',
'gen_ai.request.model': 'gpt-3.5-turbo',
Expand All @@ -55,8 +55,8 @@ describe('OpenAI integration', () => {
'openai.usage.completion_tokens': 8,
'openai.usage.prompt_tokens': 5,
},
description: 'chat gpt-3.5-turbo',
op: 'gen_ai.chat',
description: 'responses gpt-3.5-turbo',
op: 'gen_ai.responses',
origin: 'manual',
status: 'ok',
}),
Expand Down Expand Up @@ -105,8 +105,8 @@ describe('OpenAI integration', () => {
// Fifth span - responses API streaming
expect.objectContaining({
data: {
'gen_ai.operation.name': 'chat',
'sentry.op': 'gen_ai.chat',
'gen_ai.operation.name': 'responses',
'sentry.op': 'gen_ai.responses',
'sentry.origin': 'manual',
'gen_ai.system': 'openai',
'gen_ai.request.model': 'gpt-4',
Expand All @@ -124,8 +124,8 @@ describe('OpenAI integration', () => {
'openai.usage.completion_tokens': 10,
'openai.usage.prompt_tokens': 6,
},
description: 'chat gpt-4 stream-response',
op: 'gen_ai.chat',
description: 'responses gpt-4 stream-response',
op: 'gen_ai.responses',
origin: 'manual',
status: 'ok',
}),
Expand Down Expand Up @@ -182,8 +182,8 @@ describe('OpenAI integration', () => {
// Second span - responses API with PII
expect.objectContaining({
data: {
'gen_ai.operation.name': 'chat',
'sentry.op': 'gen_ai.chat',
'gen_ai.operation.name': 'responses',
'sentry.op': 'gen_ai.responses',
'sentry.origin': 'manual',
'gen_ai.system': 'openai',
'gen_ai.request.model': 'gpt-3.5-turbo',
Expand All @@ -201,8 +201,8 @@ describe('OpenAI integration', () => {
'openai.usage.completion_tokens': 8,
'openai.usage.prompt_tokens': 5,
},
description: 'chat gpt-3.5-turbo',
op: 'gen_ai.chat',
description: 'responses gpt-3.5-turbo',
op: 'gen_ai.responses',
origin: 'manual',
status: 'ok',
}),
Expand Down Expand Up @@ -255,8 +255,8 @@ describe('OpenAI integration', () => {
// Fifth span - responses API streaming with PII
expect.objectContaining({
data: expect.objectContaining({
'gen_ai.operation.name': 'chat',
'sentry.op': 'gen_ai.chat',
'gen_ai.operation.name': 'responses',
'sentry.op': 'gen_ai.responses',
'sentry.origin': 'manual',
'gen_ai.system': 'openai',
'gen_ai.request.model': 'gpt-4',
Expand All @@ -276,8 +276,8 @@ describe('OpenAI integration', () => {
'openai.usage.completion_tokens': 10,
'openai.usage.prompt_tokens': 6,
}),
description: 'chat gpt-4 stream-response',
op: 'gen_ai.chat',
description: 'responses gpt-4 stream-response',
op: 'gen_ai.responses',
origin: 'manual',
status: 'ok',
}),
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/utils/gen-ai-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,5 @@ export const OPENAI_RESPONSE_STREAM_ATTRIBUTE = 'openai.response.stream';
*/
export const OPENAI_OPERATIONS = {
CHAT: 'chat',
RESPONSES: 'responses',
} as const;
3 changes: 1 addition & 2 deletions packages/core/src/utils/openai/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export function getOperationName(methodPath: string): string {
return OPENAI_OPERATIONS.CHAT;
}
if (methodPath.includes('responses')) {
// The responses API is also a chat operation
return OPENAI_OPERATIONS.CHAT;
return OPENAI_OPERATIONS.RESPONSES;
}
return methodPath.split('.').pop() || 'unknown';
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/test/lib/utils/openai-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ describe('openai-utils', () => {
expect(getOperationName('some.path.chat.completions.method')).toBe('chat');
});

it('should return chat for responses methods', () => {
expect(getOperationName('responses.create')).toBe('chat');
expect(getOperationName('some.path.responses.method')).toBe('chat');
it('should return responses for responses methods', () => {
expect(getOperationName('responses.create')).toBe('responses');
expect(getOperationName('some.path.responses.method')).toBe('responses');
});

it('should return the last part of path for unknown methods', () => {
Expand All @@ -35,7 +35,7 @@ describe('openai-utils', () => {
describe('getSpanOperation', () => {
it('should prefix operation with gen_ai', () => {
expect(getSpanOperation('chat.completions.create')).toBe('gen_ai.chat');
expect(getSpanOperation('responses.create')).toBe('gen_ai.chat');
expect(getSpanOperation('responses.create')).toBe('gen_ai.responses');
expect(getSpanOperation('some.custom.operation')).toBe('gen_ai.operation');
});
});
Expand Down
Loading