|
1 | 1 | /* eslint-disable max-lines */ |
2 | | -import { getClient } from '../../currentScopes'; |
3 | 2 | import { captureException } from '../../exports'; |
4 | 3 | import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes'; |
5 | 4 | import { SPAN_STATUS_ERROR } from '../../tracing'; |
6 | | -import { hasSpanStreamingEnabled } from '../../tracing/spans/hasSpanStreamingEnabled'; |
7 | 5 | import { startSpan, startSpanManual } from '../../tracing/trace'; |
8 | 6 | import type { Span, SpanAttributeValue } from '../../types-hoist/span'; |
9 | 7 | import { handleCallbackErrors } from '../../utils/handleCallbackErrors'; |
@@ -36,6 +34,7 @@ import { |
36 | 34 | getJsonString, |
37 | 35 | getTruncatedJsonString, |
38 | 36 | resolveAIRecordingOptions, |
| 37 | + shouldEnableTruncation, |
39 | 38 | } from '../ai/utils'; |
40 | 39 | import { GOOGLE_GENAI_METHOD_REGISTRY, GOOGLE_GENAI_SYSTEM_NAME } from './constants'; |
41 | 40 | import { instrumentStream } from './streaming'; |
@@ -299,9 +298,12 @@ function instrumentMethod<T extends unknown[], R>( |
299 | 298 | async (span: Span) => { |
300 | 299 | try { |
301 | 300 | if (options.recordInputs && params) { |
302 | | - const client = getClient(); |
303 | | - const enableTruncation = options.enableTruncation ?? !(client && hasSpanStreamingEnabled(client)); |
304 | | - addPrivateRequestAttributes(span, params, isEmbeddings, enableTruncation); |
| 301 | + addPrivateRequestAttributes( |
| 302 | + span, |
| 303 | + params, |
| 304 | + isEmbeddings, |
| 305 | + shouldEnableTruncation(options.enableTruncation), |
| 306 | + ); |
305 | 307 | } |
306 | 308 | const stream = await target.apply(context, args); |
307 | 309 | return instrumentStream(stream, span, Boolean(options.recordOutputs)) as R; |
@@ -329,9 +331,7 @@ function instrumentMethod<T extends unknown[], R>( |
329 | 331 | }, |
330 | 332 | (span: Span) => { |
331 | 333 | if (options.recordInputs && params) { |
332 | | - const client = getClient(); |
333 | | - const enableTruncation = options.enableTruncation ?? !(client && hasSpanStreamingEnabled(client)); |
334 | | - addPrivateRequestAttributes(span, params, isEmbeddings, enableTruncation); |
| 334 | + addPrivateRequestAttributes(span, params, isEmbeddings, shouldEnableTruncation(options.enableTruncation)); |
335 | 335 | } |
336 | 336 |
|
337 | 337 | return handleCallbackErrors( |
|
0 commit comments