-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsuppression.ts
More file actions
27 lines (24 loc) · 935 Bytes
/
suppression.ts
File metadata and controls
27 lines (24 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { getCurrentScope, withScope } from '../../currentScopes';
import type { Scope } from '../../scope';
const SUPPRESS_AI_PROVIDER_SPANS_KEY = '__SENTRY_SUPPRESS_AI_PROVIDER_SPANS__';
/**
* Check if AI provider spans should be suppressed in the current scope.
*
* @internal
*/
export function _INTERNAL_isAiProviderSpanSuppressed(): boolean {
return getCurrentScope().getScopeData().sdkProcessingMetadata[SUPPRESS_AI_PROVIDER_SPANS_KEY] === true;
}
/**
* Execute a callback with AI provider spans suppressed in the current scope.
* This is used by higher-level integrations (like LangChain) to prevent
* duplicate spans from underlying AI provider instrumentations.
*
* @internal
*/
export function _INTERNAL_withSuppressedAiProviderSpans<T>(callback: () => T): T {
return withScope((scope: Scope) => {
scope.setSDKProcessingMetadata({ [SUPPRESS_AI_PROVIDER_SPANS_KEY]: true });
return callback();
});
}