Skip to content

Conversation

@RulaKhaled
Copy link
Member

@RulaKhaled RulaKhaled commented Oct 20, 2025

When using higher-level integrations that wrap underlying libraries, both the wrapper integration and the underlying library integration can instrument the same API calls, resulting in duplicate spans. This is particularly problematic for:

  • LangChain wrapping AI providers (OpenAI, Anthropic, Google GenAI)
  • Any future integrations that wrap other instrumented libraries

The disabled integrations mechanism can be used as follows:

// Any integration can disable others to prevent conflicts
import { disableIntegrations, isIntegrationDisabled } from '@sentry/node-core';

// In higher-level integration's setupOnce():
disableIntegrations('LowerLevelIntegration');

// In lower-level integration's setupOnce() or _patch():
if (isIntegrationDisabled('LowerLevelIntegration')) {
  return; // Skip instrumentation
}

and is used in LangChain to auto disable OpenAI, Anthropic AI, and Google GenAI integrations in setupOnce().

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.63 kB - -
@sentry/browser - with treeshaking flags 23.11 kB - -
@sentry/browser (incl. Tracing) 40.97 kB - -
@sentry/browser (incl. Tracing, Profiling) 45.26 kB - -
@sentry/browser (incl. Tracing, Replay) 79.29 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.97 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 83.99 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.16 kB - -
@sentry/browser (incl. Feedback) 41.3 kB - -
@sentry/browser (incl. sendFeedback) 29.29 kB - -
@sentry/browser (incl. FeedbackAsync) 34.22 kB - -
@sentry/react 26.31 kB - -
@sentry/react (incl. Tracing) 42.97 kB - -
@sentry/vue 29.11 kB - -
@sentry/vue (incl. Tracing) 42.75 kB - -
@sentry/svelte 24.64 kB - -
CDN Bundle 26.9 kB - -
CDN Bundle (incl. Tracing) 41.62 kB - -
CDN Bundle (incl. Tracing, Replay) 77.87 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.35 kB - -
CDN Bundle - uncompressed 78.86 kB - -
CDN Bundle (incl. Tracing) - uncompressed 123.44 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.48 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251.24 kB - -
@sentry/nextjs (client) 45.11 kB - -
@sentry/sveltekit (client) 41.4 kB - -
@sentry/node-core 50.75 kB +0.01% +1 B 🔺
@sentry/node 157 kB +0.05% +73 B 🔺
@sentry/node - without tracing 92.63 kB - -
@sentry/aws-serverless 106.35 kB -0.01% -3 B 🔽

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,552 - 9,475 -10%
GET With Sentry 1,296 15% 1,349 -4%
GET With Sentry (error only) 5,893 69% 6,020 -2%
POST Baseline 1,165 - 1,189 -2%
POST With Sentry 492 42% 513 -4%
POST With Sentry (error only) 1,040 89% 1,072 -3%
MYSQL Baseline 3,280 - 3,320 -1%
MYSQL With Sentry 333 10% 431 -23%
MYSQL With Sentry (error only) 2,705 82% 2,688 +1%

View base workflow run

@RulaKhaled RulaKhaled force-pushed the disable-integrations branch from fd71786 to 79b5d89 Compare October 22, 2025 14:50
@RulaKhaled RulaKhaled force-pushed the disable-integrations branch from 470034b to 31cce57 Compare October 23, 2025 09:14
@RulaKhaled RulaKhaled marked this pull request as ready for review October 23, 2025 09:16
@cursor
Copy link

cursor bot commented Oct 23, 2025

Bug: Race Condition in AI Provider Setup

A race condition exists where the LangChain integration's setupOnce() method disables other AI provider integrations to prevent duplicate spans. However, if an AI provider's setupOnce() runs before LangChain's due to unpredictable integration setup order, it will instrument itself, leading to duplicate spans that this disabling mechanism intends to prevent.

Fix in Cursor Fix in Web

@RulaKhaled RulaKhaled marked this pull request as draft October 23, 2025 12:44
@RulaKhaled RulaKhaled changed the title feat(node-core): Add integration disabling mechanism to prevent instrumentation conflicts wip feat(node-core): Add integration disabling mechanism to prevent instrumentation conflicts Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants