Skip to content

fix(core): Fix operation name for openai responses API #17206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Loading