Skip to content

Commit 330a00e

Browse files
committed
Use shouldEnableTruncation in OpenAI integration
1 parent 41546f5 commit 330a00e

File tree

1 file changed

+3
-8
lines changed
  • packages/core/src/tracing/openai

1 file changed

+3
-8
lines changed

packages/core/src/tracing/openai/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getClient } from '../../currentScopes';
21
import { DEBUG_BUILD } from '../../debug-build';
32
import { captureException } from '../../exports';
43
import { 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';
2928
import { OPENAI_METHOD_REGISTRY } from './constants';
3029
import { instrumentStream } from './streaming';
3130
import 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

Comments
 (0)