Skip to content

Commit 461b8ed

Browse files
committed
update names
1 parent df823f4 commit 461b8ed

File tree

5 files changed

+47
-52
lines changed

5 files changed

+47
-52
lines changed

packages/core/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ export {
6060
addIntegration,
6161
defineIntegration,
6262
installedIntegrations,
63-
disableIntegrations,
64-
isIntegrationDisabled,
65-
enableIntegration,
66-
clearDisabledIntegrations,
63+
_markIntegrationsDisabled,
64+
_isIntegrationMarkedDisabled,
65+
_clearDisabledIntegrationsMarks,
6766
} from './integration';
6867
export { applyScopeDataToEvent, mergeScopeData } from './utils/applyScopeDataToEvent';
6968
export { prepareEvent } from './utils/prepareEvent';

packages/core/src/integration.ts

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,55 @@ import { debug } from './utils/debug-logger';
99
export const installedIntegrations: string[] = [];
1010

1111
/**
12-
* Registry to track disabled integrations.
12+
* Registry to track integrations marked as disabled.
1313
* This is used to prevent duplicate instrumentation when higher-level integrations
1414
* (like LangChain) already instrument the underlying libraries (like OpenAI, Anthropic, etc.)
1515
*/
16-
const DISABLED_INTEGRATIONS = new Set<string>();
16+
const MARKED_DISABLED_INTEGRATIONS = new Set<string>();
1717

1818
/**
1919
* Mark one or more integrations as disabled to prevent their instrumentation from being set up.
20-
* @param integrationName The name(s) of the integration(s) to disable
20+
* This should be called during an integration's setupOnce() phase.
21+
* The marked integrations will be skipped when their own setupOnce() is called.
22+
*
23+
* @internal This is an internal API for coordination between integrations, not for public use.
24+
* @param integrationName The name(s) of the integration(s) to mark as disabled
2125
*/
22-
export function disableIntegrations(integrationName: string | string[]): void {
26+
export function _markIntegrationsDisabled(integrationName: string | string[]): void {
2327
if (Array.isArray(integrationName)) {
24-
integrationName.forEach(name => DISABLED_INTEGRATIONS.add(name));
28+
integrationName.forEach(name => MARKED_DISABLED_INTEGRATIONS.add(name));
2529
} else {
26-
DISABLED_INTEGRATIONS.add(integrationName);
30+
MARKED_DISABLED_INTEGRATIONS.add(integrationName);
2731
}
2832
}
2933

3034
/**
31-
* Check if an integration has been disabled.
35+
* Check if an integration has been marked as disabled.
36+
*
37+
* @internal This is an internal API for coordination between integrations, not for public use.
3238
* @param integrationName The name of the integration to check
33-
* @returns true if the integration is disabled
34-
*/
35-
export function isIntegrationDisabled(integrationName: string): boolean {
36-
return DISABLED_INTEGRATIONS.has(integrationName);
37-
}
38-
39-
/**
40-
* Remove one or more integrations from the disabled list.
41-
* @param integrationName The name(s) of the integration(s) to enable
39+
* @returns true if the integration is marked as disabled
4240
*/
43-
export function enableIntegration(integrationName: string | string[]): void {
44-
if (Array.isArray(integrationName)) {
45-
integrationName.forEach(name => DISABLED_INTEGRATIONS.delete(name));
46-
} else {
47-
DISABLED_INTEGRATIONS.delete(integrationName);
48-
}
41+
export function _isIntegrationMarkedDisabled(integrationName: string): boolean {
42+
return MARKED_DISABLED_INTEGRATIONS.has(integrationName);
4943
}
5044

5145
/**
52-
* Clear all disabled integrations.
53-
* This is automatically called during Sentry.init() to ensure a clean state.
46+
* Clear all integration marks and remove marked integrations from the installed list.
47+
* This is automatically called at the start of Sentry.init() to ensure a clean state
48+
* between different client initializations.
5449
*
55-
* This also removes the disabled integrations from the global installedIntegrations list,
50+
* This also removes the marked integrations from the global installedIntegrations list,
5651
* allowing them to run setupOnce() again if they're included in a new client.
52+
*
53+
* @internal This is an internal API for coordination between integrations, not for public use.
5754
*/
58-
export function clearDisabledIntegrations(): void {
59-
// Remove disabled integrations from the installed list so they can setup again
60-
DISABLED_INTEGRATIONS.forEach(integrationName => {
61-
const index = installedIntegrations.indexOf(integrationName);
62-
if (index !== -1) {
63-
installedIntegrations.splice(index, 1);
64-
}
65-
});
55+
export function _clearDisabledIntegrationsMarks(): void {
56+
// Remove marked integrations from the installed list so they can setup again
57+
const filtered = installedIntegrations.filter(integration => !MARKED_DISABLED_INTEGRATIONS.has(integration));
58+
installedIntegrations.splice(0, installedIntegrations.length, ...filtered);
6659

67-
DISABLED_INTEGRATIONS.clear();
60+
MARKED_DISABLED_INTEGRATIONS.clear();
6861
}
6962

7063
/** Map of integrations assigned to a client */
@@ -166,9 +159,9 @@ export function setupIntegration(client: Client, integration: Integration, integ
166159
integrationIndex[integration.name] = integration;
167160

168161
// `setupOnce` is only called the first time
169-
if (installedIntegrations.indexOf(integration.name) === -1 && typeof integration.setupOnce === 'function') {
170-
// Skip setup if integration is disabled
171-
if (!isIntegrationDisabled(integration.name)) {
162+
if (!installedIntegrations.includes(integration.name) && typeof integration.setupOnce === 'function') {
163+
// Skip setup if integration is marked as disabled
164+
if (!_isIntegrationMarkedDisabled(integration.name)) {
172165
integration.setupOnce();
173166
installedIntegrations.push(integration.name);
174167
}

packages/node-core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ export {
113113
captureSession,
114114
endSession,
115115
addIntegration,
116-
disableIntegrations,
117116
startSpan,
118117
startSpanManual,
119118
startInactiveSpan,

packages/node-core/src/sdk/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
55
import type { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
66
import type { DynamicSamplingContext, Scope, ServerRuntimeClientOptions, TraceContext } from '@sentry/core';
77
import {
8+
_clearDisabledIntegrationsMarks,
89
_INTERNAL_flushLogsBuffer,
910
applySdkMetadata,
10-
clearDisabledIntegrations,
1111
debug,
1212
SDK_VERSION,
1313
ServerRuntimeClient,
@@ -154,10 +154,10 @@ export class NodeClient extends ServerRuntimeClient<NodeClientOptions> {
154154

155155
/** @inheritDoc */
156156
protected _setupIntegrations(): void {
157-
// Clear disabled integrations before setting up integrations
157+
// Clear integration marks before setting up integrations
158158
// This ensures that integrations work correctly when not all default integrations are used
159-
// (e.g., when LangChain disables OpenAI, but a subsequent client doesn't use LangChain)
160-
clearDisabledIntegrations();
159+
// (e.g., when LangChain marks OpenAI as disabled, but a subsequent client doesn't use LangChain)
160+
_clearDisabledIntegrationsMarks();
161161
super._setupIntegrations();
162162
}
163163

packages/node/src/integrations/tracing/langchain/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { IntegrationFn, LangChainOptions } from '@sentry/core';
22
import {
3+
_markIntegrationsDisabled,
34
ANTHROPIC_AI_INTEGRATION_NAME,
45
defineIntegration,
5-
disableIntegrations,
66
GOOGLE_GENAI_INTEGRATION_NAME,
77
LANGCHAIN_INTEGRATION_NAME,
88
OPENAI_INTEGRATION_NAME,
@@ -19,9 +19,13 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
1919
return {
2020
name: LANGCHAIN_INTEGRATION_NAME,
2121
setupOnce() {
22-
// Disable AI provider integrations to prevent duplicate spans
22+
// Mark AI provider integrations as disabled to prevent duplicate spans
2323
// LangChain integration handles instrumentation for all underlying AI providers
24-
disableIntegrations([OPENAI_INTEGRATION_NAME, ANTHROPIC_AI_INTEGRATION_NAME, GOOGLE_GENAI_INTEGRATION_NAME]);
24+
_markIntegrationsDisabled([
25+
OPENAI_INTEGRATION_NAME,
26+
ANTHROPIC_AI_INTEGRATION_NAME,
27+
GOOGLE_GENAI_INTEGRATION_NAME,
28+
]);
2529

2630
instrumentLangChain(options);
2731
},
@@ -36,9 +40,9 @@ const _langChainIntegration = ((options: LangChainOptions = {}) => {
3640
* When configured, this integration automatically instruments LangChain runnable instances
3741
* to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.
3842
*
39-
* **Important:** This integration automatically disables the OpenAI, Anthropic, and Google GenAI
40-
* integrations to prevent duplicate spans when using LangChain with these providers. LangChain
41-
* handles the instrumentation for all underlying AI providers.
43+
* **Important:** This integration automatically marks the OpenAI, Anthropic, and Google GenAI
44+
* integrations as disabled to prevent duplicate spans when using LangChain with these providers.
45+
* LangChain handles the instrumentation for all underlying AI providers.
4246
*
4347
* @example
4448
* ```javascript

0 commit comments

Comments
 (0)