Skip to content

Commit b536a7c

Browse files
nicohrubecclaude
andauthored
ref(core): Use @sentry/conventions for gen_ai attributes (#22552)
Replace the gen_ai attributes that we currently maintain in a local constants file with `@sentry/conventions`. For now just doing 1:1 replacements, so no breaking changes. For the remaining attributes in the file we can either remove or adjust/update them based on the sentry conventions. Also we are still using some deprecated attributes from sentry conventions that we should adjust as part of the major. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c7492eb commit b536a7c

45 files changed

Lines changed: 2143 additions & 2388 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev-packages/cloudflare-integration-tests/suites/tracing/anthropic-ai/test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { expect, it } from 'vitest';
22
import {
3-
GEN_AI_OPERATION_NAME_ATTRIBUTE,
4-
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
5-
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
6-
GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,
7-
GEN_AI_RESPONSE_ID_ATTRIBUTE,
8-
GEN_AI_RESPONSE_MODEL_ATTRIBUTE,
9-
GEN_AI_SYSTEM_ATTRIBUTE,
10-
GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,
11-
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
12-
GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,
13-
} from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
3+
GEN_AI_OPERATION_NAME,
4+
GEN_AI_REQUEST_MAX_TOKENS,
5+
GEN_AI_REQUEST_MODEL,
6+
GEN_AI_REQUEST_TEMPERATURE,
7+
GEN_AI_RESPONSE_ID,
8+
GEN_AI_RESPONSE_MODEL,
9+
GEN_AI_SYSTEM,
10+
GEN_AI_USAGE_INPUT_TOKENS,
11+
GEN_AI_USAGE_OUTPUT_TOKENS,
12+
GEN_AI_USAGE_TOTAL_TOKENS,
13+
} from '@sentry/conventions/attributes';
1414
import { createRunner } from '../../../runner';
1515

1616
// This test runs the `@anthropic-ai/sdk` on the Workers runtime (with a
@@ -40,16 +40,16 @@ it('traces a basic message creation request with the anthropic SDK', async ({ si
4040
attributes: {
4141
'sentry.origin': { value: 'auto.ai.anthropic', type: 'string' },
4242
'sentry.op': { value: 'gen_ai.chat', type: 'string' },
43-
[GEN_AI_SYSTEM_ATTRIBUTE]: { value: 'anthropic', type: 'string' },
44-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { value: 'chat', type: 'string' },
45-
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: { value: 'claude-3-haiku-20240307', type: 'string' },
46-
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: { value: 0.7, type: 'double' },
47-
[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE]: { value: 100, type: 'integer' },
48-
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: { value: 'msg_mock123', type: 'string' },
49-
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: { value: 'claude-3-haiku-20240307', type: 'string' },
50-
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: { value: 10, type: 'integer' },
51-
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: { value: 15, type: 'integer' },
52-
[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: { value: 25, type: 'integer' },
43+
[GEN_AI_SYSTEM]: { value: 'anthropic', type: 'string' },
44+
[GEN_AI_OPERATION_NAME]: { value: 'chat', type: 'string' },
45+
[GEN_AI_REQUEST_MODEL]: { value: 'claude-3-haiku-20240307', type: 'string' },
46+
[GEN_AI_REQUEST_TEMPERATURE]: { value: 0.7, type: 'double' },
47+
[GEN_AI_REQUEST_MAX_TOKENS]: { value: 100, type: 'integer' },
48+
[GEN_AI_RESPONSE_ID]: { value: 'msg_mock123', type: 'string' },
49+
[GEN_AI_RESPONSE_MODEL]: { value: 'claude-3-haiku-20240307', type: 'string' },
50+
[GEN_AI_USAGE_INPUT_TOKENS]: { value: 10, type: 'integer' },
51+
[GEN_AI_USAGE_OUTPUT_TOKENS]: { value: 15, type: 'integer' },
52+
[GEN_AI_USAGE_TOTAL_TOKENS]: { value: 25, type: 'integer' },
5353
},
5454
});
5555
})

dev-packages/cloudflare-integration-tests/suites/tracing/google-genai/test.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { expect, it } from 'vitest';
22
import type { SerializedStreamedSpan } from '@sentry/core';
33
import {
4-
GEN_AI_OPERATION_NAME_ATTRIBUTE,
5-
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
6-
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
7-
GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,
8-
GEN_AI_REQUEST_TOP_P_ATTRIBUTE,
9-
GEN_AI_SYSTEM_ATTRIBUTE,
10-
GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,
11-
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
12-
GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,
13-
} from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
4+
GEN_AI_OPERATION_NAME,
5+
GEN_AI_REQUEST_MAX_TOKENS,
6+
GEN_AI_REQUEST_MODEL,
7+
GEN_AI_REQUEST_TEMPERATURE,
8+
GEN_AI_REQUEST_TOP_P,
9+
GEN_AI_SYSTEM,
10+
GEN_AI_USAGE_INPUT_TOKENS,
11+
GEN_AI_USAGE_OUTPUT_TOKENS,
12+
GEN_AI_USAGE_TOTAL_TOKENS,
13+
} from '@sentry/conventions/attributes';
1414
import { createRunner } from '../../../runner';
1515

1616
// This test runs the `@google/genai` SDK on the Workers runtime (with a
@@ -43,12 +43,12 @@ it('traces Google GenAI chat, generateContent, and embedContent calls', async ({
4343
attributes: {
4444
'sentry.origin': { value: 'auto.ai.google_genai', type: 'string' },
4545
'sentry.op': { value: 'gen_ai.chat', type: 'string' },
46-
[GEN_AI_SYSTEM_ATTRIBUTE]: { value: 'google_genai', type: 'string' },
47-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { value: 'chat', type: 'string' },
48-
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: { value: 'gemini-1.5-pro', type: 'string' },
49-
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: { value: 8, type: 'integer' },
50-
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: { value: 12, type: 'integer' },
51-
[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: { value: 20, type: 'integer' },
46+
[GEN_AI_SYSTEM]: { value: 'google_genai', type: 'string' },
47+
[GEN_AI_OPERATION_NAME]: { value: 'chat', type: 'string' },
48+
[GEN_AI_REQUEST_MODEL]: { value: 'gemini-1.5-pro', type: 'string' },
49+
[GEN_AI_USAGE_INPUT_TOKENS]: { value: 8, type: 'integer' },
50+
[GEN_AI_USAGE_OUTPUT_TOKENS]: { value: 12, type: 'integer' },
51+
[GEN_AI_USAGE_TOTAL_TOKENS]: { value: 20, type: 'integer' },
5252
},
5353
});
5454

@@ -64,15 +64,15 @@ it('traces Google GenAI chat, generateContent, and embedContent calls', async ({
6464
attributes: {
6565
'sentry.origin': { value: 'auto.ai.google_genai', type: 'string' },
6666
'sentry.op': { value: 'gen_ai.generate_content', type: 'string' },
67-
[GEN_AI_SYSTEM_ATTRIBUTE]: { value: 'google_genai', type: 'string' },
68-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { value: 'generate_content', type: 'string' },
69-
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: { value: 'gemini-1.5-flash', type: 'string' },
70-
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: { value: 0.7, type: 'double' },
71-
[GEN_AI_REQUEST_TOP_P_ATTRIBUTE]: { value: 0.9, type: 'double' },
72-
[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE]: { value: 100, type: 'integer' },
73-
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: { value: 8, type: 'integer' },
74-
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: { value: 12, type: 'integer' },
75-
[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: { value: 20, type: 'integer' },
67+
[GEN_AI_SYSTEM]: { value: 'google_genai', type: 'string' },
68+
[GEN_AI_OPERATION_NAME]: { value: 'generate_content', type: 'string' },
69+
[GEN_AI_REQUEST_MODEL]: { value: 'gemini-1.5-flash', type: 'string' },
70+
[GEN_AI_REQUEST_TEMPERATURE]: { value: 0.7, type: 'double' },
71+
[GEN_AI_REQUEST_TOP_P]: { value: 0.9, type: 'double' },
72+
[GEN_AI_REQUEST_MAX_TOKENS]: { value: 100, type: 'integer' },
73+
[GEN_AI_USAGE_INPUT_TOKENS]: { value: 8, type: 'integer' },
74+
[GEN_AI_USAGE_OUTPUT_TOKENS]: { value: 12, type: 'integer' },
75+
[GEN_AI_USAGE_TOTAL_TOKENS]: { value: 20, type: 'integer' },
7676
},
7777
});
7878

@@ -88,9 +88,9 @@ it('traces Google GenAI chat, generateContent, and embedContent calls', async ({
8888
attributes: {
8989
'sentry.origin': { value: 'auto.ai.google_genai', type: 'string' },
9090
'sentry.op': { value: 'gen_ai.embeddings', type: 'string' },
91-
[GEN_AI_SYSTEM_ATTRIBUTE]: { value: 'google_genai', type: 'string' },
92-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { value: 'embeddings', type: 'string' },
93-
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: { value: 'text-embedding-004', type: 'string' },
91+
[GEN_AI_SYSTEM]: { value: 'google_genai', type: 'string' },
92+
[GEN_AI_OPERATION_NAME]: { value: 'embeddings', type: 'string' },
93+
[GEN_AI_REQUEST_MODEL]: { value: 'text-embedding-004', type: 'string' },
9494
},
9595
});
9696
})

dev-packages/cloudflare-integration-tests/suites/tracing/langchain/test.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { expect, it } from 'vitest';
22
import {
3-
GEN_AI_OPERATION_NAME_ATTRIBUTE,
4-
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
5-
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
6-
GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,
7-
GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,
8-
GEN_AI_RESPONSE_ID_ATTRIBUTE,
9-
GEN_AI_RESPONSE_MODEL_ATTRIBUTE,
10-
GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE,
11-
GEN_AI_SYSTEM_ATTRIBUTE,
12-
GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,
13-
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
14-
GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,
15-
} from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
3+
GEN_AI_OPERATION_NAME,
4+
GEN_AI_REQUEST_MAX_TOKENS,
5+
GEN_AI_REQUEST_MODEL,
6+
GEN_AI_REQUEST_TEMPERATURE,
7+
GEN_AI_RESPONSE_FINISH_REASONS,
8+
GEN_AI_RESPONSE_ID,
9+
GEN_AI_RESPONSE_MODEL,
10+
GEN_AI_SYSTEM,
11+
GEN_AI_USAGE_INPUT_TOKENS,
12+
GEN_AI_USAGE_OUTPUT_TOKENS,
13+
GEN_AI_USAGE_TOTAL_TOKENS,
14+
} from '@sentry/conventions/attributes';
15+
import { GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE } from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
1616
import { createRunner } from '../../../runner';
1717

1818
// This test runs the `@langchain/openai` model (backed by the
@@ -42,17 +42,17 @@ it('traces a LangChain chat model invocation', async ({ signal }) => {
4242
attributes: {
4343
'sentry.origin': { value: 'auto.ai.langchain', type: 'string' },
4444
'sentry.op': { value: 'gen_ai.chat', type: 'string' },
45-
[GEN_AI_SYSTEM_ATTRIBUTE]: { value: 'openai', type: 'string' },
46-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { value: 'chat', type: 'string' },
47-
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: { value: 'gpt-3.5-turbo', type: 'string' },
48-
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: { value: 0.7, type: 'double' },
49-
[GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE]: { value: 100, type: 'integer' },
50-
[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE]: { value: '["stop"]', type: 'string' },
51-
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: { value: 10, type: 'integer' },
52-
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: { value: 15, type: 'integer' },
53-
[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: { value: 25, type: 'integer' },
54-
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: { value: 'gpt-3.5-turbo', type: 'string' },
55-
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: { value: 'chatcmpl-mock123', type: 'string' },
45+
[GEN_AI_SYSTEM]: { value: 'openai', type: 'string' },
46+
[GEN_AI_OPERATION_NAME]: { value: 'chat', type: 'string' },
47+
[GEN_AI_REQUEST_MODEL]: { value: 'gpt-3.5-turbo', type: 'string' },
48+
[GEN_AI_REQUEST_TEMPERATURE]: { value: 0.7, type: 'double' },
49+
[GEN_AI_REQUEST_MAX_TOKENS]: { value: 100, type: 'integer' },
50+
[GEN_AI_RESPONSE_FINISH_REASONS]: { value: '["stop"]', type: 'string' },
51+
[GEN_AI_USAGE_INPUT_TOKENS]: { value: 10, type: 'integer' },
52+
[GEN_AI_USAGE_OUTPUT_TOKENS]: { value: 15, type: 'integer' },
53+
[GEN_AI_USAGE_TOTAL_TOKENS]: { value: 25, type: 'integer' },
54+
[GEN_AI_RESPONSE_MODEL]: { value: 'gpt-3.5-turbo', type: 'string' },
55+
[GEN_AI_RESPONSE_ID]: { value: 'chatcmpl-mock123', type: 'string' },
5656
[GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE]: { value: 'stop', type: 'string' },
5757
},
5858
});

dev-packages/cloudflare-integration-tests/suites/tracing/langgraph/test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { expect, it } from 'vitest';
22
import type { SerializedStreamedSpan } from '@sentry/core';
33
import {
4-
GEN_AI_AGENT_NAME_ATTRIBUTE,
5-
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
6-
GEN_AI_OPERATION_NAME_ATTRIBUTE,
7-
GEN_AI_PIPELINE_NAME_ATTRIBUTE,
8-
GEN_AI_RESPONSE_MODEL_ATTRIBUTE,
9-
GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,
10-
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
11-
GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,
12-
} from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
4+
GEN_AI_AGENT_NAME,
5+
GEN_AI_INPUT_MESSAGES,
6+
GEN_AI_OPERATION_NAME,
7+
GEN_AI_PIPELINE_NAME,
8+
GEN_AI_RESPONSE_MODEL,
9+
GEN_AI_USAGE_INPUT_TOKENS,
10+
GEN_AI_USAGE_OUTPUT_TOKENS,
11+
GEN_AI_USAGE_TOTAL_TOKENS,
12+
} from '@sentry/conventions/attributes';
1313
import { createRunner } from '../../../runner';
1414

1515
// These tests are not exhaustive because the instrumentation is
@@ -40,13 +40,13 @@ it('traces langgraph compile and invoke operations', async ({ signal }) => {
4040
);
4141
expect(createAgentSpan).toBeDefined();
4242
expect(createAgentSpan!.status).toBe('ok');
43-
expect(createAgentSpan!.attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE]).toEqual({
43+
expect(createAgentSpan!.attributes[GEN_AI_OPERATION_NAME]).toEqual({
4444
type: 'string',
4545
value: 'create_agent',
4646
});
4747
expect(createAgentSpan!.attributes['sentry.op']).toEqual({ type: 'string', value: 'gen_ai.create_agent' });
4848
expect(createAgentSpan!.attributes['sentry.origin']).toEqual({ type: 'string', value: 'auto.ai.langgraph' });
49-
expect(createAgentSpan!.attributes[GEN_AI_AGENT_NAME_ATTRIBUTE]).toEqual({
49+
expect(createAgentSpan!.attributes[GEN_AI_AGENT_NAME]).toEqual({
5050
type: 'string',
5151
value: 'weather_assistant',
5252
});
@@ -56,37 +56,37 @@ it('traces langgraph compile and invoke operations', async ({ signal }) => {
5656
);
5757
expect(invokeAgentSpan).toBeDefined();
5858
expect(invokeAgentSpan!.status).toBe('ok');
59-
expect(invokeAgentSpan!.attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE]).toEqual({
59+
expect(invokeAgentSpan!.attributes[GEN_AI_OPERATION_NAME]).toEqual({
6060
type: 'string',
6161
value: 'invoke_agent',
6262
});
6363
expect(invokeAgentSpan!.attributes['sentry.op']).toEqual({ type: 'string', value: 'gen_ai.invoke_agent' });
6464
expect(invokeAgentSpan!.attributes['sentry.origin']).toEqual({ type: 'string', value: 'auto.ai.langgraph' });
65-
expect(invokeAgentSpan!.attributes[GEN_AI_AGENT_NAME_ATTRIBUTE]).toEqual({
65+
expect(invokeAgentSpan!.attributes[GEN_AI_AGENT_NAME]).toEqual({
6666
type: 'string',
6767
value: 'weather_assistant',
6868
});
69-
expect(invokeAgentSpan!.attributes[GEN_AI_PIPELINE_NAME_ATTRIBUTE]).toEqual({
69+
expect(invokeAgentSpan!.attributes[GEN_AI_PIPELINE_NAME]).toEqual({
7070
type: 'string',
7171
value: 'weather_assistant',
7272
});
73-
expect(invokeAgentSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]).toEqual({
73+
expect(invokeAgentSpan!.attributes[GEN_AI_INPUT_MESSAGES]).toEqual({
7474
type: 'string',
7575
value: '[{"role":"user","content":"What is the weather in SF?"}]',
7676
});
77-
expect(invokeAgentSpan!.attributes[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]).toEqual({
77+
expect(invokeAgentSpan!.attributes[GEN_AI_RESPONSE_MODEL]).toEqual({
7878
type: 'string',
7979
value: 'mock-model',
8080
});
81-
expect(invokeAgentSpan!.attributes[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]).toEqual({
81+
expect(invokeAgentSpan!.attributes[GEN_AI_USAGE_INPUT_TOKENS]).toEqual({
8282
type: 'integer',
8383
value: 20,
8484
});
85-
expect(invokeAgentSpan!.attributes[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]).toEqual({
85+
expect(invokeAgentSpan!.attributes[GEN_AI_USAGE_OUTPUT_TOKENS]).toEqual({
8686
type: 'integer',
8787
value: 10,
8888
});
89-
expect(invokeAgentSpan!.attributes[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]).toEqual({
89+
expect(invokeAgentSpan!.attributes[GEN_AI_USAGE_TOTAL_TOKENS]).toEqual({
9090
type: 'integer',
9191
value: 30,
9292
});

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { expect, it } from 'vitest';
22
import {
3-
GEN_AI_OPERATION_NAME_ATTRIBUTE,
4-
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
5-
GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE,
6-
GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,
7-
GEN_AI_RESPONSE_ID_ATTRIBUTE,
8-
GEN_AI_RESPONSE_MODEL_ATTRIBUTE,
9-
GEN_AI_SYSTEM_ATTRIBUTE,
10-
GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,
11-
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
12-
GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,
13-
} from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
3+
GEN_AI_OPERATION_NAME,
4+
GEN_AI_REQUEST_MODEL,
5+
GEN_AI_REQUEST_TEMPERATURE,
6+
GEN_AI_RESPONSE_FINISH_REASONS,
7+
GEN_AI_RESPONSE_ID,
8+
GEN_AI_RESPONSE_MODEL,
9+
GEN_AI_SYSTEM,
10+
GEN_AI_USAGE_INPUT_TOKENS,
11+
GEN_AI_USAGE_OUTPUT_TOKENS,
12+
GEN_AI_USAGE_TOTAL_TOKENS,
13+
} from '@sentry/conventions/attributes';
1414
import { createRunner } from '../../../runner';
1515

1616
// This test runs the `openai` SDK on the Workers runtime (with a canned
@@ -40,16 +40,16 @@ it('traces a basic chat completion request with the openai SDK', async ({ signal
4040
attributes: {
4141
'sentry.origin': { value: 'auto.ai.openai', type: 'string' },
4242
'sentry.op': { value: 'gen_ai.chat', type: 'string' },
43-
[GEN_AI_SYSTEM_ATTRIBUTE]: { value: 'openai', type: 'string' },
44-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { value: 'chat', type: 'string' },
45-
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: { value: 'gpt-3.5-turbo', type: 'string' },
46-
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: { value: 0.7, type: 'double' },
47-
[GEN_AI_RESPONSE_ID_ATTRIBUTE]: { value: 'chatcmpl-mock123', type: 'string' },
48-
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: { value: 'gpt-3.5-turbo', type: 'string' },
49-
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: { value: 10, type: 'integer' },
50-
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: { value: 15, type: 'integer' },
51-
[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: { value: 25, type: 'integer' },
52-
[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE]: { value: '["stop"]', type: 'string' },
43+
[GEN_AI_SYSTEM]: { value: 'openai', type: 'string' },
44+
[GEN_AI_OPERATION_NAME]: { value: 'chat', type: 'string' },
45+
[GEN_AI_REQUEST_MODEL]: { value: 'gpt-3.5-turbo', type: 'string' },
46+
[GEN_AI_REQUEST_TEMPERATURE]: { value: 0.7, type: 'double' },
47+
[GEN_AI_RESPONSE_ID]: { value: 'chatcmpl-mock123', type: 'string' },
48+
[GEN_AI_RESPONSE_MODEL]: { value: 'gpt-3.5-turbo', type: 'string' },
49+
[GEN_AI_USAGE_INPUT_TOKENS]: { value: 10, type: 'integer' },
50+
[GEN_AI_USAGE_OUTPUT_TOKENS]: { value: 15, type: 'integer' },
51+
[GEN_AI_USAGE_TOTAL_TOKENS]: { value: 25, type: 'integer' },
52+
[GEN_AI_RESPONSE_FINISH_REASONS]: { value: '["stop"]', type: 'string' },
5353
},
5454
});
5555
})

dev-packages/cloudflare-integration-tests/suites/tracing/vercelai/als_v6/test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { expect, it } from 'vitest';
22
import {
3-
GEN_AI_OPERATION_NAME_ATTRIBUTE,
4-
GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE,
5-
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
6-
GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,
7-
} from '../../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
3+
GEN_AI_OPERATION_NAME,
4+
GEN_AI_USAGE_INPUT_TOKENS,
5+
GEN_AI_USAGE_OUTPUT_TOKENS,
6+
GEN_AI_USAGE_TOTAL_TOKENS,
7+
} from '@sentry/conventions/attributes';
88
import { createRunner } from '../../../../runner';
99

1010
it('captures a transaction with Vercel AI v6 spans via @sentry/cloudflare vercelAIIntegration', async ({ signal }) => {
@@ -32,10 +32,10 @@ it('captures a transaction with Vercel AI v6 spans via @sentry/cloudflare vercel
3232
attributes: expect.objectContaining({
3333
'sentry.op': { type: 'string', value: 'gen_ai.invoke_agent' },
3434
'sentry.origin': { type: 'string', value: 'auto.vercelai.otel' },
35-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { type: 'string', value: 'invoke_agent' },
36-
[GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE]: { type: 'integer', value: 10 },
37-
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: { type: 'integer', value: 20 },
38-
[GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE]: { type: 'integer', value: 30 },
35+
[GEN_AI_OPERATION_NAME]: { type: 'string', value: 'invoke_agent' },
36+
[GEN_AI_USAGE_INPUT_TOKENS]: { type: 'integer', value: 10 },
37+
[GEN_AI_USAGE_OUTPUT_TOKENS]: { type: 'integer', value: 20 },
38+
[GEN_AI_USAGE_TOTAL_TOKENS]: { type: 'integer', value: 30 },
3939
}),
4040
},
4141
{
@@ -50,7 +50,7 @@ it('captures a transaction with Vercel AI v6 spans via @sentry/cloudflare vercel
5050
attributes: expect.objectContaining({
5151
'sentry.op': { type: 'string', value: 'gen_ai.generate_content' },
5252
'sentry.origin': { type: 'string', value: 'auto.vercelai.otel' },
53-
[GEN_AI_OPERATION_NAME_ATTRIBUTE]: { type: 'string', value: 'generate_content' },
53+
[GEN_AI_OPERATION_NAME]: { type: 'string', value: 'generate_content' },
5454
}),
5555
},
5656
]),

0 commit comments

Comments
 (0)