Skip to content

Commit 4fa02f8

Browse files
nicohrubecclaude
andcommitted
feat(core)!: Remove sentry.sdk_meta.gen_ai.input.messages.original_length attribute
This internal SDK-meta span attribute only ever signaled how many gen_ai input messages existed before truncation dropped some. It carries no meaning for consumers on its own and is being removed ahead of the truncation removal. Text truncation itself is unchanged by this commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 29f97f5 commit 4fa02f8

24 files changed

Lines changed: 26 additions & 201 deletions

File tree

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ Sentry.init({
393393
### AI integrations
394394

395395
- The `enableTruncation` and `streamGenAiSpans` flags were removed. The new default is no truncation and to always stream gen AI spans.
396+
- The internal `sentry.sdk_meta.gen_ai.input.messages.original_length` span attribute was removed.
396397
- (Vercel AI) The internal JSON-stringify workaround for array span attributes was removed.
397398
- AI integrations are no longer available in the browser SDK. They remain available in the server-side SDKs.
398399

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { afterAll, describe, expect } from 'vitest';
22
import {
33
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
4-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
54
GEN_AI_OPERATION_NAME_ATTRIBUTE,
65
GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,
76
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
@@ -634,7 +633,6 @@ describe('Anthropic integration', () => {
634633
expect(truncatedSpan!.attributes['sentry.origin'].value).toBe('auto.ai.anthropic');
635634
expect(truncatedSpan!.attributes[GEN_AI_SYSTEM_ATTRIBUTE].value).toBe('anthropic');
636635
expect(truncatedSpan!.attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE].value).toBe('claude-3-haiku-20240307');
637-
expect(truncatedSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
638636

639637
const smallMessageSpan = container.items.find(
640638
span => span.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]?.value === smallMsgValue,
@@ -649,7 +647,6 @@ describe('Anthropic integration', () => {
649647
expect(smallMessageSpan!.attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE].value).toBe(
650648
'claude-3-haiku-20240307',
651649
);
652-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
653650
},
654651
})
655652
.start()
@@ -700,7 +697,6 @@ describe('Anthropic integration', () => {
700697
expect(firstSpan!.attributes['sentry.origin'].value).toBe('auto.ai.anthropic');
701698
expect(firstSpan!.attributes[GEN_AI_SYSTEM_ATTRIBUTE].value).toBe('anthropic');
702699
expect(firstSpan!.attributes[GEN_AI_REQUEST_MODEL_ATTRIBUTE].value).toBe('claude-3-haiku-20240307');
703-
expect(firstSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(2);
704700
},
705701
})
706702
.start()
@@ -767,13 +763,11 @@ describe('Anthropic integration', () => {
767763
span => span.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]?.value === expectedAllMessages,
768764
);
769765
expect(conversationSpan).toBeDefined();
770-
expect(conversationSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
771766

772767
const longStringSpan = container.items.find(
773768
span => span.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]?.value === expectedLongString,
774769
);
775770
expect(longStringSpan).toBeDefined();
776-
expect(longStringSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(1);
777771
},
778772
})
779773
.start()

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,
44
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
55
GEN_AI_OPERATION_NAME_ATTRIBUTE,
6-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
76
GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,
87
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
98
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
@@ -368,7 +367,6 @@ describe('Google GenAI integration', () => {
368367
expect(truncatedSpan!.name).toBe('generate_content gemini-1.5-flash');
369368
expect(truncatedSpan!.status).toBe('ok');
370369
expect(truncatedSpan!.attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE].value).toBe('generate_content');
371-
expect(truncatedSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
372370

373371
const smallMessageSpan = container.items.find(
374372
span =>
@@ -384,7 +382,6 @@ describe('Google GenAI integration', () => {
384382
expect(smallMessageSpan!.name).toBe('generate_content gemini-1.5-flash');
385383
expect(smallMessageSpan!.status).toBe('ok');
386384
expect(smallMessageSpan!.attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE].value).toBe('generate_content');
387-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
388385
},
389386
})
390387
.start()
@@ -532,7 +529,6 @@ describe('Google GenAI integration', () => {
532529
{ role: 'user', parts: [{ text: 'Follow-up question' }] },
533530
]),
534531
);
535-
expect(firstSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
536532
},
537533
})
538534
.start()

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
GEN_AI_EMBEDDINGS_INPUT_ATTRIBUTE,
44
GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,
55
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
6-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
76
GEN_AI_OPERATION_NAME_ATTRIBUTE,
87
GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE,
98
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
@@ -210,20 +209,25 @@ describe('LangChain integration', () => {
210209
.expect({
211210
span: container => {
212211
expect(container.items).toHaveLength(3);
212+
// The string-input span has no system message (and therefore no system instructions),
213+
// while the array-input span does — use that to distinguish the two truncated spans.
214+
const truncatedContent = /^\[\{"role":"user","content":"C+"\}\]$/;
213215
const stringInputSpan = container.items.find(
214-
span => span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 1,
216+
span =>
217+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE] === undefined &&
218+
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]?.value)?.match(
219+
truncatedContent,
220+
),
215221
);
216222
expect(stringInputSpan).toBeDefined();
217223
expect(stringInputSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
218-
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE].value).toMatch(
219-
/^\[\{"role":"user","content":"C+"\}\]$/,
220-
);
224+
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE].value).toMatch(truncatedContent);
221225

222226
const arrayInputSpan = container.items.find(
223227
span =>
224-
span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 2 &&
228+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE] !== undefined &&
225229
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]?.value)?.match(
226-
/^\[\{"role":"user","content":"C+"\}\]$/,
230+
truncatedContent,
227231
),
228232
);
229233
expect(arrayInputSpan).toBeDefined();
@@ -237,7 +241,6 @@ describe('LangChain integration', () => {
237241
);
238242
expect(smallMessageSpan).toBeDefined();
239243
expect(smallMessageSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
240-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(2);
241244
expect(smallMessageSpan!.attributes[GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE]).toBeDefined();
242245
},
243246
})
@@ -476,7 +479,6 @@ describe('LangChain integration', () => {
476479
{ role: 'user', content: 'Follow-up question' },
477480
]),
478481
);
479-
expect(firstSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
480482
},
481483
})
482484
.start()

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { afterAll, expect } from 'vitest';
22
import {
33
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
4-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
54
GEN_AI_OPERATION_NAME_ATTRIBUTE,
65
GEN_AI_REQUEST_MAX_TOKENS_ATTRIBUTE,
76
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
@@ -226,20 +225,25 @@ conditionalTest({ min: 20 })('LangChain integration (v1)', () => {
226225
.expect({
227226
span: container => {
228227
expect(container.items).toHaveLength(3);
228+
// The string-input span has no system message (and therefore no system instructions),
229+
// while the array-input span does — use that to distinguish the two truncated spans.
230+
const truncatedContent = /^\[\{"role":"user","content":"C+"\}\]$/;
229231
const stringInputSpan = container.items.find(
230-
span => span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 1,
232+
span =>
233+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE] === undefined &&
234+
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]?.value)?.match(
235+
truncatedContent,
236+
),
231237
);
232238
expect(stringInputSpan).toBeDefined();
233239
expect(stringInputSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
234-
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE].value).toMatch(
235-
/^\[\{"role":"user","content":"C+"\}\]$/,
236-
);
240+
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE].value).toMatch(truncatedContent);
237241

238242
const arrayInputSpan = container.items.find(
239243
span =>
240-
span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 2 &&
244+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE] !== undefined &&
241245
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]?.value)?.match(
242-
/^\[\{"role":"user","content":"C+"\}\]$/,
246+
truncatedContent,
243247
),
244248
);
245249
expect(arrayInputSpan).toBeDefined();
@@ -255,7 +259,6 @@ conditionalTest({ min: 20 })('LangChain integration (v1)', () => {
255259
);
256260
expect(smallMessageSpan).toBeDefined();
257261
expect(smallMessageSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
258-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(2);
259262
expect(smallMessageSpan!.attributes[GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE].value).toMatch(
260263
/^\[\{"type":"text","content":"A+"\}\]$/,
261264
);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
GEN_AI_AGENT_NAME_ATTRIBUTE,
55
GEN_AI_CONVERSATION_ID_ATTRIBUTE,
66
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
7-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
87
GEN_AI_OPERATION_NAME_ATTRIBUTE,
98
GEN_AI_PIPELINE_NAME_ATTRIBUTE,
109
GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,
@@ -305,7 +304,6 @@ describe('LangGraph integration', () => {
305304

306305
expect(invokeAgentSpan).toBeDefined();
307306
expect(invokeAgentSpan!.name).toBe('invoke_agent weather_assistant');
308-
expect(invokeAgentSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
309307
},
310308
})
311309
.start()

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '
22
import { afterAll, describe, expect } from 'vitest';
33
import {
44
GEN_AI_INPUT_MESSAGES_ATTRIBUTE,
5-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
65
GEN_AI_OPERATION_NAME_ATTRIBUTE,
76
GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE,
87
GEN_AI_REQUEST_MODEL_ATTRIBUTE,
@@ -355,10 +354,6 @@ describe('OpenAI Tool Calls integration', () => {
355354
type: 'string',
356355
value: 'gpt-4',
357356
});
358-
expect(chatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
359-
type: 'integer',
360-
value: 1,
361-
});
362357
expect(chatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]).toEqual({
363358
type: 'string',
364359
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',
@@ -430,10 +425,6 @@ describe('OpenAI Tool Calls integration', () => {
430425
type: 'boolean',
431426
value: true,
432427
});
433-
expect(streamingChatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
434-
type: 'integer',
435-
value: 1,
436-
});
437428
expect(streamingChatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]).toEqual({
438429
type: 'string',
439430
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',
@@ -502,10 +493,6 @@ describe('OpenAI Tool Calls integration', () => {
502493
value: 'gpt-4',
503494
});
504495
expect(responsesToolsSpan!.attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE]).toBeUndefined();
505-
expect(responsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
506-
type: 'integer',
507-
value: 1,
508-
});
509496
expect(responsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]).toEqual({
510497
type: 'string',
511498
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',
@@ -573,10 +560,6 @@ describe('OpenAI Tool Calls integration', () => {
573560
type: 'boolean',
574561
value: true,
575562
});
576-
expect(streamingResponsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
577-
type: 'integer',
578-
value: 1,
579-
});
580563
expect(streamingResponsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ATTRIBUTE]).toEqual({
581564
type: 'string',
582565
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',

0 commit comments

Comments
 (0)