@@ -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}
0 commit comments