Skip to content

Commit d984087

Browse files
committed
fix(core): Fix operation name for responses api
1 parent 0cebb57 commit d984087

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

dev-packages/node-integration-tests/suites/tracing/openai/test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ describe('OpenAI integration', () => {
3838
// Second span - responses API
3939
expect.objectContaining({
4040
data: {
41-
'gen_ai.operation.name': 'chat',
42-
'sentry.op': 'gen_ai.chat',
41+
'gen_ai.operation.name': 'responses',
42+
'sentry.op': 'gen_ai.responses',
4343
'sentry.origin': 'manual',
4444
'gen_ai.system': 'openai',
4545
'gen_ai.request.model': 'gpt-3.5-turbo',
@@ -55,8 +55,8 @@ describe('OpenAI integration', () => {
5555
'openai.usage.completion_tokens': 8,
5656
'openai.usage.prompt_tokens': 5,
5757
},
58-
description: 'chat gpt-3.5-turbo',
59-
op: 'gen_ai.chat',
58+
description: 'responses gpt-3.5-turbo',
59+
op: 'gen_ai.responses',
6060
origin: 'manual',
6161
status: 'ok',
6262
}),
@@ -105,8 +105,8 @@ describe('OpenAI integration', () => {
105105
// Fifth span - responses API streaming
106106
expect.objectContaining({
107107
data: {
108-
'gen_ai.operation.name': 'chat',
109-
'sentry.op': 'gen_ai.chat',
108+
'gen_ai.operation.name': 'responses',
109+
'sentry.op': 'gen_ai.responses',
110110
'sentry.origin': 'manual',
111111
'gen_ai.system': 'openai',
112112
'gen_ai.request.model': 'gpt-4',
@@ -124,8 +124,8 @@ describe('OpenAI integration', () => {
124124
'openai.usage.completion_tokens': 10,
125125
'openai.usage.prompt_tokens': 6,
126126
},
127-
description: 'chat gpt-4 stream-response',
128-
op: 'gen_ai.chat',
127+
description: 'responses gpt-4 stream-response',
128+
op: 'gen_ai.responses',
129129
origin: 'manual',
130130
status: 'ok',
131131
}),
@@ -182,8 +182,8 @@ describe('OpenAI integration', () => {
182182
// Second span - responses API with PII
183183
expect.objectContaining({
184184
data: {
185-
'gen_ai.operation.name': 'chat',
186-
'sentry.op': 'gen_ai.chat',
185+
'gen_ai.operation.name': 'responses',
186+
'sentry.op': 'gen_ai.responses',
187187
'sentry.origin': 'manual',
188188
'gen_ai.system': 'openai',
189189
'gen_ai.request.model': 'gpt-3.5-turbo',
@@ -201,8 +201,8 @@ describe('OpenAI integration', () => {
201201
'openai.usage.completion_tokens': 8,
202202
'openai.usage.prompt_tokens': 5,
203203
},
204-
description: 'chat gpt-3.5-turbo',
205-
op: 'gen_ai.chat',
204+
description: 'responses gpt-3.5-turbo',
205+
op: 'gen_ai.responses',
206206
origin: 'manual',
207207
status: 'ok',
208208
}),
@@ -255,8 +255,8 @@ describe('OpenAI integration', () => {
255255
// Fifth span - responses API streaming with PII
256256
expect.objectContaining({
257257
data: expect.objectContaining({
258-
'gen_ai.operation.name': 'chat',
259-
'sentry.op': 'gen_ai.chat',
258+
'gen_ai.operation.name': 'responses',
259+
'sentry.op': 'gen_ai.responses',
260260
'sentry.origin': 'manual',
261261
'gen_ai.system': 'openai',
262262
'gen_ai.request.model': 'gpt-4',
@@ -276,8 +276,8 @@ describe('OpenAI integration', () => {
276276
'openai.usage.completion_tokens': 10,
277277
'openai.usage.prompt_tokens': 6,
278278
}),
279-
description: 'chat gpt-4 stream-response',
280-
op: 'gen_ai.chat',
279+
description: 'responses gpt-4 stream-response',
280+
op: 'gen_ai.responses',
281281
origin: 'manual',
282282
status: 'ok',
283283
}),

packages/core/src/utils/gen-ai-attributes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,5 @@ export const OPENAI_RESPONSE_STREAM_ATTRIBUTE = 'openai.response.stream';
150150
*/
151151
export const OPENAI_OPERATIONS = {
152152
CHAT: 'chat',
153+
RESPONSES: 'responses',
153154
} as const;

packages/core/src/utils/openai/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export function getOperationName(methodPath: string): string {
2929
return OPENAI_OPERATIONS.CHAT;
3030
}
3131
if (methodPath.includes('responses')) {
32-
// The responses API is also a chat operation
33-
return OPENAI_OPERATIONS.CHAT;
32+
return OPENAI_OPERATIONS.RESPONSES;
3433
}
3534
return methodPath.split('.').pop() || 'unknown';
3635
}

0 commit comments

Comments
 (0)