Skip to content

Commit b9de893

Browse files
committed
.
1 parent 5a85b6c commit b9de893

File tree

2 files changed

+8
-7
lines changed
  • packages
    • core/src/tracing/vercel-ai
    • node/src/integrations/tracing/vercelai

2 files changed

+8
-7
lines changed

packages/core/src/tracing/vercel-ai/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function mapVercelAiOperationName(operationName: string): string {
9494
* Post-process spans emitted by the Vercel AI SDK.
9595
* This is supposed to be used in `client.on('spanStart', ...)
9696
*/
97-
function onVercelAiSpanStart(span: Span, enableTruncation: boolean): void {
97+
function onVercelAiSpanStart(span: Span, client: Client): void {
9898
const { data: attributes, description: name } = spanToJSON(span);
9999

100100
if (!name) {
@@ -114,6 +114,9 @@ function onVercelAiSpanStart(span: Span, enableTruncation: boolean): void {
114114
return;
115115
}
116116

117+
const integration = client.getIntegrationByName('VercelAI') as { options?: { enableTruncation?: boolean } } | undefined;
118+
const enableTruncation = integration?.options?.enableTruncation ?? true;
119+
117120
processGenerateSpan(span, name, attributes, enableTruncation);
118121
}
119122

@@ -444,9 +447,8 @@ function processGenerateSpan(span: Span, name: string, attributes: SpanAttribute
444447
/**
445448
* Add event processors to the given client to process Vercel AI spans.
446449
*/
447-
export function addVercelAiProcessors(client: Client, options?: { enableTruncation?: boolean }): void {
448-
const enableTruncation = options?.enableTruncation ?? true;
449-
client.on('spanStart', span => onVercelAiSpanStart(span, enableTruncation));
450+
export function addVercelAiProcessors(client: Client): void {
451+
client.on('spanStart', span => onVercelAiSpanStart(span, client));
450452
// Note: We cannot do this on `spanEnd`, because the span cannot be mutated anymore at this point
451453
client.addEventProcessor(Object.assign(vercelAiEventProcessor, { id: 'VercelAiEventProcessor' }));
452454
}

packages/node/src/integrations/tracing/vercelai/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
3030
// Note that this can only be detected if the 'Modules' integration is available, and running in CJS mode
3131
const shouldForce = options.force ?? shouldForceIntegration(client);
3232

33-
const processorOptions = { enableTruncation: options.enableTruncation };
3433
if (shouldForce) {
35-
addVercelAiProcessors(client, processorOptions);
34+
addVercelAiProcessors(client);
3635
} else {
37-
instrumentation?.callWhenPatched(() => addVercelAiProcessors(client, processorOptions));
36+
instrumentation?.callWhenPatched(() => addVercelAiProcessors(client));
3837
}
3938
},
4039
};

0 commit comments

Comments
 (0)