Skip to content

Commit 66ba3c1

Browse files
committed
Use shouldEnableTruncation in Google GenAI integration
1 parent d58aef2 commit 66ba3c1

File tree

1 file changed

+8
-8
lines changed
  • packages/core/src/tracing/google-genai

1 file changed

+8
-8
lines changed

packages/core/src/tracing/google-genai/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/* eslint-disable max-lines */
2-
import { getClient } from '../../currentScopes';
32
import { captureException } from '../../exports';
43
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';
54
import { SPAN_STATUS_ERROR } from '../../tracing';
6-
import { hasSpanStreamingEnabled } from '../../tracing/spans/hasSpanStreamingEnabled';
75
import { startSpan, startSpanManual } from '../../tracing/trace';
86
import type { Span, SpanAttributeValue } from '../../types-hoist/span';
97
import { handleCallbackErrors } from '../../utils/handleCallbackErrors';
@@ -36,6 +34,7 @@ import {
3634
getJsonString,
3735
getTruncatedJsonString,
3836
resolveAIRecordingOptions,
37+
shouldEnableTruncation,
3938
} from '../ai/utils';
4039
import { GOOGLE_GENAI_METHOD_REGISTRY, GOOGLE_GENAI_SYSTEM_NAME } from './constants';
4140
import { instrumentStream } from './streaming';
@@ -299,9 +298,12 @@ function instrumentMethod<T extends unknown[], R>(
299298
async (span: Span) => {
300299
try {
301300
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+
);
305307
}
306308
const stream = await target.apply(context, args);
307309
return instrumentStream(stream, span, Boolean(options.recordOutputs)) as R;
@@ -329,9 +331,7 @@ function instrumentMethod<T extends unknown[], R>(
329331
},
330332
(span: Span) => {
331333
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));
335335
}
336336

337337
return handleCallbackErrors(

0 commit comments

Comments
 (0)