Skip to content

Commit 68c20be

Browse files
committed
Add shouldEnableTruncation helper
1 parent 9021fa3 commit 68c20be

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/core/src/tracing/ai/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import { captureException } from '../../exports';
55
import { getClient } from '../../currentScopes';
6+
import { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';
67
import type { Span } from '../../types-hoist/span';
78
import { isThenable } from '../../utils/is';
89
import {
@@ -56,6 +57,16 @@ export function resolveAIRecordingOptions<T extends AIRecordingOptions>(options?
5657
} as T & Required<AIRecordingOptions>;
5758
}
5859

60+
/**
61+
* Resolves whether truncation should be enabled.
62+
* If the user explicitly set `enableTruncation`, that value is used.
63+
* Otherwise, truncation is disabled when span streaming is active.
64+
*/
65+
export function shouldEnableTruncation(enableTruncation: boolean | undefined): boolean {
66+
const client = getClient();
67+
return enableTruncation ?? !(client && hasSpanStreamingEnabled(client));
68+
}
69+
5970
/**
6071
* Build method path from current traversal
6172
*/

0 commit comments

Comments
 (0)