Skip to content

Commit d21d217

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 428912c commit d21d217

24 files changed

Lines changed: 28 additions & 222 deletions

File tree

MIGRATION.md

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

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

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ import {
1818
GEN_AI_USAGE_OUTPUT_TOKENS,
1919
GEN_AI_USAGE_TOTAL_TOKENS,
2020
} from '@sentry/conventions/attributes';
21-
import {
22-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
23-
GEN_AI_REQUEST_STREAM_ATTRIBUTE,
24-
} from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
21+
import { GEN_AI_REQUEST_STREAM_ATTRIBUTE } from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
2522
import { getStringAttributeValue, isOrchestrionEnabled } from '../../../utils';
2623
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
2724

@@ -629,7 +626,6 @@ describe('Anthropic integration', () => {
629626
expect(truncatedSpan!.attributes['sentry.origin'].value).toBe('auto.ai.orchestrion.anthropic');
630627
expect(truncatedSpan!.attributes[GEN_AI_SYSTEM].value).toBe('anthropic');
631628
expect(truncatedSpan!.attributes[GEN_AI_REQUEST_MODEL].value).toBe('claude-3-haiku-20240307');
632-
expect(truncatedSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
633629

634630
const smallMessageSpan = container.items.find(
635631
span => span.attributes[GEN_AI_INPUT_MESSAGES]?.value === smallMsgValue,
@@ -642,7 +638,6 @@ describe('Anthropic integration', () => {
642638
expect(smallMessageSpan!.attributes['sentry.origin'].value).toBe('auto.ai.orchestrion.anthropic');
643639
expect(smallMessageSpan!.attributes[GEN_AI_SYSTEM].value).toBe('anthropic');
644640
expect(smallMessageSpan!.attributes[GEN_AI_REQUEST_MODEL].value).toBe('claude-3-haiku-20240307');
645-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
646641
},
647642
})
648643
.start()
@@ -693,7 +688,6 @@ describe('Anthropic integration', () => {
693688
expect(firstSpan!.attributes['sentry.origin'].value).toBe('auto.ai.orchestrion.anthropic');
694689
expect(firstSpan!.attributes[GEN_AI_SYSTEM].value).toBe('anthropic');
695690
expect(firstSpan!.attributes[GEN_AI_REQUEST_MODEL].value).toBe('claude-3-haiku-20240307');
696-
expect(firstSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(2);
697691
},
698692
})
699693
.start()
@@ -760,13 +754,11 @@ describe('Anthropic integration', () => {
760754
span => span.attributes[GEN_AI_INPUT_MESSAGES]?.value === expectedAllMessages,
761755
);
762756
expect(conversationSpan).toBeDefined();
763-
expect(conversationSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
764757

765758
const longStringSpan = container.items.find(
766759
span => span.attributes[GEN_AI_INPUT_MESSAGES]?.value === expectedLongString,
767760
);
768761
expect(longStringSpan).toBeDefined();
769-
expect(longStringSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(1);
770762
},
771763
})
772764
.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
@@ -20,7 +20,6 @@ import {
2020
GEN_AI_USAGE_OUTPUT_TOKENS,
2121
GEN_AI_USAGE_TOTAL_TOKENS,
2222
} from '@sentry/conventions/attributes';
23-
import { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE } from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
2423
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
2524
import { getStringAttributeValue, isOrchestrionEnabled } from '../../../utils';
2625

@@ -366,7 +365,6 @@ describe('Google GenAI integration', () => {
366365
expect(truncatedSpan!.name).toBe('generate_content gemini-1.5-flash');
367366
expect(truncatedSpan!.status).toBe('ok');
368367
expect(truncatedSpan!.attributes[GEN_AI_OPERATION_NAME].value).toBe('generate_content');
369-
expect(truncatedSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
370368

371369
const smallMessageSpan = container.items.find(
372370
span =>
@@ -382,7 +380,6 @@ describe('Google GenAI integration', () => {
382380
expect(smallMessageSpan!.name).toBe('generate_content gemini-1.5-flash');
383381
expect(smallMessageSpan!.status).toBe('ok');
384382
expect(smallMessageSpan!.attributes[GEN_AI_OPERATION_NAME].value).toBe('generate_content');
385-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
386383
},
387384
})
388385
.start()
@@ -530,7 +527,6 @@ describe('Google GenAI integration', () => {
530527
{ role: 'user', parts: [{ text: 'Follow-up question' }] },
531528
]),
532529
);
533-
expect(firstSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
534530
},
535531
})
536532
.start()

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
} from '@sentry/conventions/attributes';
2020
import {
2121
GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,
22-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
2322
GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE,
2423
GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE,
2524
} from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
@@ -212,21 +211,22 @@ describe('LangChain integration', () => {
212211
.expect({
213212
span: container => {
214213
expect(container.items).toHaveLength(3);
214+
// The string-input span has no system message (and therefore no system instructions),
215+
// while the array-input span does — use that to distinguish the two truncated spans.
216+
const truncatedContent = /^\[\{"role":"user","content":"C+"\}\]$/;
215217
const stringInputSpan = container.items.find(
216-
span => span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 1,
218+
span =>
219+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS] === undefined &&
220+
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES]?.value)?.match(truncatedContent),
217221
);
218222
expect(stringInputSpan).toBeDefined();
219223
expect(stringInputSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
220-
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES].value).toMatch(
221-
/^\[\{"role":"user","content":"C+"\}\]$/,
222-
);
224+
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES].value).toMatch(truncatedContent);
223225

224226
const arrayInputSpan = container.items.find(
225227
span =>
226-
span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 2 &&
227-
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES]?.value)?.match(
228-
/^\[\{"role":"user","content":"C+"\}\]$/,
229-
),
228+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS] !== undefined &&
229+
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES]?.value)?.match(truncatedContent),
230230
);
231231
expect(arrayInputSpan).toBeDefined();
232232
expect(arrayInputSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
@@ -239,7 +239,6 @@ describe('LangChain integration', () => {
239239
);
240240
expect(smallMessageSpan).toBeDefined();
241241
expect(smallMessageSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
242-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(2);
243242
expect(smallMessageSpan!.attributes[GEN_AI_SYSTEM_INSTRUCTIONS]).toBeDefined();
244243
},
245244
})
@@ -478,7 +477,6 @@ describe('LangChain integration', () => {
478477
{ role: 'user', content: 'Follow-up question' },
479478
]),
480479
);
481-
expect(firstSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
482480
},
483481
})
484482
.start()

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import {
1616
GEN_AI_USAGE_OUTPUT_TOKENS,
1717
GEN_AI_USAGE_TOTAL_TOKENS,
1818
} from '@sentry/conventions/attributes';
19-
import {
20-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
21-
GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE,
22-
} from '../../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
19+
import { GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE } from '../../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
2320
import { conditionalTest, getStringAttributeValue, isOrchestrionEnabled } from '../../../../utils';
2421
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../../utils/runner';
2522
import { createEsmTests } from '../../../../utils/runner/createEsmAndCjsTests';
@@ -228,21 +225,22 @@ conditionalTest({ min: 20 })('LangChain integration (v1)', () => {
228225
.expect({
229226
span: container => {
230227
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+"\}\]$/;
231231
const stringInputSpan = container.items.find(
232-
span => span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 1,
232+
span =>
233+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS] === undefined &&
234+
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES]?.value)?.match(truncatedContent),
233235
);
234236
expect(stringInputSpan).toBeDefined();
235237
expect(stringInputSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
236-
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES].value).toMatch(
237-
/^\[\{"role":"user","content":"C+"\}\]$/,
238-
);
238+
expect(stringInputSpan!.attributes[GEN_AI_INPUT_MESSAGES].value).toMatch(truncatedContent);
239239

240240
const arrayInputSpan = container.items.find(
241241
span =>
242-
span.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]?.value === 2 &&
243-
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES]?.value)?.match(
244-
/^\[\{"role":"user","content":"C+"\}\]$/,
245-
),
242+
span.attributes[GEN_AI_SYSTEM_INSTRUCTIONS] !== undefined &&
243+
getStringAttributeValue(span.attributes[GEN_AI_INPUT_MESSAGES]?.value)?.match(truncatedContent),
246244
);
247245
expect(arrayInputSpan).toBeDefined();
248246
expect(arrayInputSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
@@ -257,7 +255,6 @@ conditionalTest({ min: 20 })('LangChain integration (v1)', () => {
257255
);
258256
expect(smallMessageSpan).toBeDefined();
259257
expect(smallMessageSpan!.name).toBe('chat claude-3-5-sonnet-20241022');
260-
expect(smallMessageSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(2);
261258
expect(smallMessageSpan!.attributes[GEN_AI_SYSTEM_INSTRUCTIONS].value).toMatch(
262259
/^\[\{"type":"text","content":"A+"\}\]$/,
263260
);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
GEN_AI_USAGE_OUTPUT_TOKENS,
1717
GEN_AI_USAGE_TOTAL_TOKENS,
1818
} from '@sentry/conventions/attributes';
19-
import { GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE } from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
2019
import { getStringAttributeValue } from '../../../utils';
2120
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
2221

@@ -298,7 +297,6 @@ describe('LangGraph integration', () => {
298297

299298
expect(invokeAgentSpan).toBeDefined();
300299
expect(invokeAgentSpan!.name).toBe('invoke_agent weather_assistant');
301-
expect(invokeAgentSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE].value).toBe(3);
302300
},
303301
})
304302
.start()

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import {
1616
GEN_AI_USAGE_OUTPUT_TOKENS,
1717
GEN_AI_USAGE_TOTAL_TOKENS,
1818
} from '@sentry/conventions/attributes';
19-
import {
20-
GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE,
21-
GEN_AI_REQUEST_STREAM_ATTRIBUTE,
22-
} from '../../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
19+
import { GEN_AI_REQUEST_STREAM_ATTRIBUTE } from '../../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
2320
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../../utils/runner';
2421

2522
describe('OpenAI Tool Calls integration', () => {
@@ -357,10 +354,6 @@ describe('OpenAI Tool Calls integration', () => {
357354
type: 'string',
358355
value: 'gpt-4',
359356
});
360-
expect(chatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
361-
type: 'integer',
362-
value: 1,
363-
});
364357
expect(chatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES]).toEqual({
365358
type: 'string',
366359
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',
@@ -432,10 +425,6 @@ describe('OpenAI Tool Calls integration', () => {
432425
type: 'boolean',
433426
value: true,
434427
});
435-
expect(streamingChatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
436-
type: 'integer',
437-
value: 1,
438-
});
439428
expect(streamingChatToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES]).toEqual({
440429
type: 'string',
441430
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',
@@ -504,10 +493,6 @@ describe('OpenAI Tool Calls integration', () => {
504493
value: 'gpt-4',
505494
});
506495
expect(responsesToolsSpan!.attributes[GEN_AI_REQUEST_STREAM_ATTRIBUTE]).toBeUndefined();
507-
expect(responsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
508-
type: 'integer',
509-
value: 1,
510-
});
511496
expect(responsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES]).toEqual({
512497
type: 'string',
513498
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',
@@ -575,10 +560,6 @@ describe('OpenAI Tool Calls integration', () => {
575560
type: 'boolean',
576561
value: true,
577562
});
578-
expect(streamingResponsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]).toEqual({
579-
type: 'integer',
580-
value: 1,
581-
});
582563
expect(streamingResponsesToolsSpan!.attributes[GEN_AI_INPUT_MESSAGES]).toEqual({
583564
type: 'string',
584565
value: '[{"role":"user","content":"What is the weather like in Paris today?"}]',

0 commit comments

Comments
 (0)