Skip to content

Commit d634385

Browse files
authored
fix(node): Fix check for performance integrations (#12043)
ref #12034 cc @AbhiPrasad when you're back, let's look again at `hasTracingEnabled()` and see if we want to adjust this maybe.
1 parent ccb98ff commit d634385

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/node/src/sdk/init.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,23 @@ export function getDefaultIntegrationsWithoutPerformance(): Integration[] {
7878
export function getDefaultIntegrations(options: Options): Integration[] {
7979
return [
8080
...getDefaultIntegrationsWithoutPerformance(),
81-
...(hasTracingEnabled(options) ? getAutoPerformanceIntegrations() : []),
81+
// We only add performance integrations if tracing is enabled
82+
// Note that this means that without tracing enabled, e.g. `expressIntegration()` will not be added
83+
// This means that generally request isolation will work (because that is done by httpIntegration)
84+
// But `transactionName` will not be set automatically
85+
...(shouldAddPerformanceIntegrations(options) ? getAutoPerformanceIntegrations() : []),
8286
];
8387
}
8488

89+
function shouldAddPerformanceIntegrations(options: Options): boolean {
90+
if (!hasTracingEnabled(options)) {
91+
return false;
92+
}
93+
94+
// We want to ensure `tracesSampleRate` is not just undefined/null here
95+
return options.enableTracing || options.tracesSampleRate != null || 'tracesSampler' in options;
96+
}
97+
8598
declare const __IMPORT_META_URL_REPLACEMENT__: string;
8699

87100
/**

0 commit comments

Comments
 (0)