Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ Affected SDKs: All SDKs.
- The `gen_ai.system` span attribute was renamed to `gen_ai.provider.name` across all AI integrations.
- The `gen_ai.request.available_tools` span attribute was renamed to `gen_ai.tool.definitions` across all AI integrations.
- The `gen_ai.tool.input` span attribute was renamed to `gen_ai.tool.call.arguments` across all AI integrations.
- The `gen_ai.tool.output` span attribute was renamed to `gen_ai.tool.call.result` across all AI integrations.
- Span attributes now use the shared `@sentry/conventions` package under the hood.

If you reference these attributes in custom instrumentation, `beforeSendSpan`, dashboards, or alerts, update them to the new names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
GEN_AI_REQUEST_MODEL,
GEN_AI_RESPONSE_MODEL,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_DESCRIPTION,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_OUTPUT_TOKENS,
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('Vercel AI integration (streaming v4)', () => {
[GEN_AI_TOOL_DESCRIPTION]: attr('Get the current weather for a location'),
[GEN_AI_TOOL_CALL_ARGUMENTS]: expect.objectContaining({ value: expect.any(String) }),
[GEN_AI_TOOL_NAME]: attr('getWeather'),
[GEN_AI_TOOL_OUTPUT]: expect.objectContaining({ value: expect.any(String) }),
[GEN_AI_TOOL_CALL_RESULT]: expect.objectContaining({ value: expect.any(String) }),
[GEN_AI_TOOL_TYPE]: attr('function'),
[GEN_AI_OPERATION_NAME]: attr('execute_tool'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: attr('gen_ai.execute_tool'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
GEN_AI_REQUEST_MODEL,
GEN_AI_RESPONSE_MODEL,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_DESCRIPTION,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_OUTPUT_TOKENS,
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('Vercel AI integration (streaming, v6)', () => {
[GEN_AI_TOOL_DESCRIPTION]: attr('Get the current weather for a location'),
[GEN_AI_TOOL_CALL_ARGUMENTS]: expect.objectContaining({ value: expect.any(String) }),
[GEN_AI_TOOL_NAME]: attr('getWeather'),
[GEN_AI_TOOL_OUTPUT]: expect.objectContaining({ value: expect.any(String) }),
[GEN_AI_TOOL_CALL_RESULT]: expect.objectContaining({ value: expect.any(String) }),
[GEN_AI_TOOL_TYPE]: attr('function'),
[GEN_AI_OPERATION_NAME]: attr('execute_tool'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: attr('gen_ai.execute_tool'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
GEN_AI_RESPONSE_MODEL,
GEN_AI_SYSTEM_INSTRUCTIONS,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_DESCRIPTION,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_OUTPUT_TOKENS,
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('Vercel AI integration (v4)', () => {
'Get the current weather for a location',
);
expect(toolExecutionSpan!.attributes[GEN_AI_TOOL_CALL_ARGUMENTS]).toBeDefined();
expect(toolExecutionSpan!.attributes[GEN_AI_TOOL_OUTPUT]).toBeDefined();
expect(toolExecutionSpan!.attributes[GEN_AI_TOOL_CALL_RESULT]).toBeDefined();
},
})
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
GEN_AI_REQUEST_MODEL,
GEN_AI_RESPONSE_MODEL,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_DESCRIPTION,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_OUTPUT_TOKENS,
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('Vercel AI integration (v5)', () => {
'Get the current weather for a location',
);
expect(toolExecutionSpan!.attributes[GEN_AI_TOOL_CALL_ARGUMENTS]).toBeDefined();
expect(toolExecutionSpan!.attributes[GEN_AI_TOOL_OUTPUT]).toBeDefined();
expect(toolExecutionSpan!.attributes[GEN_AI_TOOL_CALL_RESULT]).toBeDefined();
},
})
.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
GEN_AI_RESPONSE_MODEL,
GEN_AI_SYSTEM_INSTRUCTIONS,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_DESCRIPTION,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_INPUT_TOKENS_CACHED,
Expand Down Expand Up @@ -151,7 +151,7 @@ describe.each(matrix)('Vercel AI integration (version %s)', (version, vercelAiVe
'Get the current weather for a location',
);
expect(toolExecutionSpan.attributes[GEN_AI_TOOL_CALL_ARGUMENTS]).toBeDefined();
expect(toolExecutionSpan.attributes[GEN_AI_TOOL_OUTPUT]).toBeDefined();
expect(toolExecutionSpan.attributes[GEN_AI_TOOL_CALL_RESULT]).toBeDefined();
},
})
.start()
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/tracing/langchain/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable typescript-eslint/no-deprecated */
/* eslint-disable max-lines */
import { captureException } from '../../exports';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';
Expand All @@ -9,9 +8,9 @@ import {
GEN_AI_OPERATION_NAME,
GEN_AI_REQUEST_MODEL,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
} from '@sentry/conventions/attributes';
import { resolveAIRecordingOptions, shouldEnableTruncation } from '../ai/utils';
import { LANGCHAIN_ORIGIN } from './constants';
Expand Down Expand Up @@ -328,7 +327,7 @@ export function createLangChainCallbackHandler(options: LangChainOptions = {}):
const content =
outputObj && typeof outputObj === 'object' && 'content' in outputObj ? outputObj.content : output;
span.setAttributes({
[GEN_AI_TOOL_OUTPUT]: typeof content === 'string' ? content : JSON.stringify(content),
[GEN_AI_TOOL_CALL_RESULT]: typeof content === 'string' ? content : JSON.stringify(content),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: Should we be more defensive with the stringifying? I think we have a helper for that now 🤔.

});
}
exitSpan(runId);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/tracing/langgraph/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
GEN_AI_RESPONSE_TEXT,
GEN_AI_RESPONSE_TOOL_CALLS,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DESCRIPTION,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_OUTPUT_TOKENS,
Expand Down Expand Up @@ -130,7 +130,7 @@ export function wrapToolsWithSpans(tools: unknown[], options: LangGraphOptions,
const content =
resultObj && typeof resultObj === 'object' && 'content' in resultObj ? resultObj.content : result;
span.setAttribute(
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_CALL_RESULT,
typeof content === 'string' ? content : JSON.stringify(content),
);
} catch {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/tracing/vercel-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
GEN_AI_REQUEST_MODEL,
GEN_AI_RESPONSE_MODEL,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_DESCRIPTION,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_INPUT_TOKENS_CACHED,
Expand Down Expand Up @@ -320,7 +320,7 @@ export function processVercelAiSpanAttributes(attributes: Record<string, unknown
renameAttributeKey(attributes, AI_PROMPT_TOOLS_ATTRIBUTE, GEN_AI_TOOL_DEFINITIONS);

renameAttributeKey(attributes, AI_TOOL_CALL_ARGS_ATTRIBUTE, GEN_AI_TOOL_CALL_ARGUMENTS);
renameAttributeKey(attributes, AI_TOOL_CALL_RESULT_ATTRIBUTE, GEN_AI_TOOL_OUTPUT);
renameAttributeKey(attributes, AI_TOOL_CALL_RESULT_ATTRIBUTE, GEN_AI_TOOL_CALL_RESULT);

renameAttributeKey(attributes, AI_SCHEMA_ATTRIBUTE, 'gen_ai.request.schema');
renameAttributeKey(attributes, AI_MODEL_ID_ATTRIBUTE, GEN_AI_REQUEST_MODEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
GEN_AI_RESPONSE_STREAMING,
GEN_AI_SYSTEM_INSTRUCTIONS,
GEN_AI_TOOL_CALL_ARGUMENTS,
GEN_AI_TOOL_CALL_RESULT,
GEN_AI_TOOL_DEFINITIONS,
GEN_AI_TOOL_NAME,
GEN_AI_TOOL_OUTPUT,
GEN_AI_TOOL_TYPE,
GEN_AI_USAGE_INPUT_TOKENS,
GEN_AI_USAGE_OUTPUT_TOKENS,
Expand Down Expand Up @@ -509,7 +509,7 @@ export function enrichSpanOnEnd(

if (type === 'executeTool') {
if (recordOutputs) {
span.setAttribute(GEN_AI_TOOL_OUTPUT, stringify(result.output ?? result));
span.setAttribute(GEN_AI_TOOL_CALL_RESULT, stringify(result.output ?? result));
}
// From V5 on, tool errors are not rejected (so the `error` channel verb never fires) — they
// surface as `tool-error` content on the resolved result. Mirror the OTel path by marking the
Expand Down
Loading