1- import { getClient } from '../../currentScopes' ;
21import { DEBUG_BUILD } from '../../debug-build' ;
32import { captureException } from '../../exports' ;
43import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes' ;
@@ -23,9 +22,9 @@ import {
2322 getJsonString ,
2423 getTruncatedJsonString ,
2524 resolveAIRecordingOptions ,
25+ shouldEnableTruncation ,
2626 wrapPromiseWithMethods ,
2727} from '../ai/utils' ;
28- import { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled' ;
2928import { OPENAI_METHOD_REGISTRY } from './constants' ;
3029import { instrumentStream } from './streaming' ;
3130import type { ChatCompletionChunk , OpenAiOptions , OpenAIStream , ResponseStreamingEvent } from './types' ;
@@ -172,9 +171,7 @@ function instrumentMethod<T extends unknown[], R>(
172171 originalResult = originalMethod . apply ( context , args ) ;
173172
174173 if ( options . recordInputs && params ) {
175- const client = getClient ( ) ;
176- const enableTruncation = options . enableTruncation ?? ! ( client && hasSpanStreamingEnabled ( client ) ) ;
177- addRequestAttributes ( span , params , operationName , enableTruncation ) ;
174+ addRequestAttributes ( span , params , operationName , shouldEnableTruncation ( options . enableTruncation ) ) ;
178175 }
179176
180177 // Return async processing
@@ -212,9 +209,7 @@ function instrumentMethod<T extends unknown[], R>(
212209 originalResult = originalMethod . apply ( context , args ) ;
213210
214211 if ( options . recordInputs && params ) {
215- const client = getClient ( ) ;
216- const enableTruncation = options . enableTruncation ?? ! ( client && hasSpanStreamingEnabled ( client ) ) ;
217- addRequestAttributes ( span , params , operationName , enableTruncation ) ;
212+ addRequestAttributes ( span , params , operationName , shouldEnableTruncation ( options . enableTruncation ) ) ;
218213 }
219214
220215 return originalResult . then (
0 commit comments