@sentry/core
Version:
Base implementation for all Sentry JavaScript SDKs
35 lines (30 loc) • 1.65 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
// Global map to track tool call IDs to their corresponding span contexts.
// This allows us to capture tool errors and link them to the correct span
// without keeping full Span objects (and their potentially large attributes) alive.
const toolCallSpanContextMap = new Map();
// Used to make tool descriptions available to execute_tool spans in the span streaming path.
// Streamed spans are processed individually, so execute_tool spans cannot look up descriptions
// from their sibling doGenerate span on span end (as we do for transactions).
// Instead we store descriptions at spanStart and apply them in the processSpan hook.
// Stores parent_span_id -> Map<toolName, description>
const toolDescriptionMap = new Map();
/** Maps Vercel AI span names to standardized OpenTelemetry operation names. */
const SPAN_TO_OPERATION_NAME = new Map([
['ai.generateText', 'invoke_agent'],
['ai.streamText', 'invoke_agent'],
['ai.generateObject', 'invoke_agent'],
['ai.streamObject', 'invoke_agent'],
['ai.generateText.doGenerate', 'generate_content'],
['ai.streamText.doStream', 'generate_content'],
['ai.generateObject.doGenerate', 'generate_content'],
['ai.streamObject.doStream', 'generate_content'],
['ai.embed.doEmbed', 'embeddings'],
['ai.embedMany.doEmbed', 'embeddings'],
['ai.rerank.doRerank', 'rerank'],
['ai.toolCall', 'execute_tool'],
]);
exports.SPAN_TO_OPERATION_NAME = SPAN_TO_OPERATION_NAME;
exports.toolCallSpanContextMap = toolCallSpanContextMap;
exports.toolDescriptionMap = toolDescriptionMap;
//# sourceMappingURL=constants.js.map