From dd1365c0ff949d3091181f31c46dba1fd3abfa93 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 15 May 2024 13:33:44 +0200 Subject: [PATCH] fix(node): Fix check for performance integrations --- packages/node/src/sdk/init.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/node/src/sdk/init.ts b/packages/node/src/sdk/init.ts index 5ca3a743531a..c03af9ec09d5 100644 --- a/packages/node/src/sdk/init.ts +++ b/packages/node/src/sdk/init.ts @@ -78,10 +78,23 @@ export function getDefaultIntegrationsWithoutPerformance(): Integration[] { export function getDefaultIntegrations(options: Options): Integration[] { return [ ...getDefaultIntegrationsWithoutPerformance(), - ...(hasTracingEnabled(options) ? getAutoPerformanceIntegrations() : []), + // We only add performance integrations if tracing is enabled + // Note that this means that without tracing enabled, e.g. `expressIntegration()` will not be added + // This means that generally request isolation will work (because that is done by httpIntegration) + // But `transactionName` will not be set automatically + ...(shouldAddPerformanceIntegrations(options) ? getAutoPerformanceIntegrations() : []), ]; } +function shouldAddPerformanceIntegrations(options: Options): boolean { + if (!hasTracingEnabled(options)) { + return false; + } + + // We want to ensure `tracesSampleRate` is not just undefined/null here + return options.enableTracing || options.tracesSampleRate != null || 'tracesSampler' in options; +} + declare const __IMPORT_META_URL_REPLACEMENT__: string; /**