-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(core): Instrument invoke_agent root span, and support Vercel ai
v5
#17395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
size-limit report 📦
|
fd2fb4c
to
7d41fa7
Compare
ai
v5
ai
v5 ai
v5
@@ -118,6 +118,7 @@ export type { ReportDialogOptions } from './report-dialog'; | |||
export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer, _INTERNAL_captureSerializedLog } from './logs/exports'; | |||
export { consoleLoggingIntegration } from './logs/console-integration'; | |||
export { addVercelAiProcessors } from './utils/vercel-ai'; | |||
export { getSpanForToolCallId, cleanupToolCallSpan } from './utils/vercel-ai/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this to be public API?
export function getSpanForToolCallId(toolCallId: string): Span | undefined { | ||
return toolCallSpanMap.get(toolCallId); | ||
} | ||
|
||
/** | ||
* Clean up the span mapping for a tool call ID | ||
*/ | ||
export function cleanupToolCallSpan(toolCallId: string): void { | ||
toolCallSpanMap.delete(toolCallId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't need to export this for users, we could also just inline this :)
scope.setTag('vercel.ai.tool.span.id', spanContext.spanId); | ||
scope.setTag('vercel.ai.tool.trace.id', spanContext.traceId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use span_id
and trace_id
here. And is there a specific reason we use tags on the scope here instead of attributes on the span? Just wondering 🤔
scope.setTag('vercel.ai.tool.span.id', spanContext.spanId); | |
scope.setTag('vercel.ai.tool.trace.id', spanContext.traceId); | |
scope.setTag('vercel.ai.tool.spanId', spanContext.span_id); | |
scope.setTag('vercel.ai.tool.traceId', spanContext.trace_id); |
Main changes are:
invoke_agent
span: This addresses that transaction event.spans only includes child spans, ensuring proper correlation beyond just children.vercelai
integration layout in core: Restructured the vercelai folder to mirror our other AI agent integrations (split constants/utils/index) for clarity and easier maintenance.