Skip to content

feat(node): Allow to force activate vercelAiIntegration #16551

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

Merged
merged 1 commit into from
Jun 11, 2025
Merged
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
10 changes: 8 additions & 2 deletions packages/node/src/integrations/tracing/vercelai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
instrumentation = instrumentVercelAi();
},
setup(client) {
instrumentation?.callWhenPatched(() => {
function registerProcessors(): void {
client.on('spanStart', span => {
const { data: attributes, description: name } = spanToJSON(span);

Expand Down Expand Up @@ -188,7 +188,13 @@ const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {

return event;
});
});
}

if (options.force) {
registerProcessors();
} else {
instrumentation?.callWhenPatched(registerProcessors);
}
},
};
}) satisfies IntegrationFn;
Expand Down
6 changes: 6 additions & 0 deletions packages/node/src/integrations/tracing/vercelai/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export interface VercelAiOptions {
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
*/
recordOutputs?: boolean;

/**
* By default, the instrumentation will register span processors only when the ai package is used.
* If you want to register the span processors even when the ai package usage cannot be detected, you can set `force` to `true`.
*/
force?: boolean;
}

export interface VercelAiIntegration extends Integration {
Expand Down
Loading