@@ -445,30 +445,39 @@ export const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> =
445
445
setup ( client : NodeClient ) {
446
446
DEBUG_BUILD && logger . log ( '[Profiling] Profiling integration setup.' ) ;
447
447
const options = client . getOptions ( ) ;
448
-
449
448
const profilingAPIVersion = getProfilingMode ( options ) ;
450
449
450
+
451
451
if ( profilingAPIVersion === 'legacy' ) {
452
- const mode = ! ( 'profileSessionSampleRate ' in options ) && ! options . profilesSampler ? 'continuous ' : 'span ' ;
452
+ const mode = ( 'profilesSampleRate ' in options || ' profilesSampler' in options ) ? 'span ' : 'continuous ' ;
453
453
454
454
switch ( mode ) {
455
455
case 'continuous' : {
456
456
DEBUG_BUILD && logger . log ( '[Profiling] Continuous profiler mode enabled.' ) ;
457
457
this . _profiler . initialize ( client ) ;
458
- break ;
458
+ return ;
459
459
}
460
460
// Default to span profiling when no mode profiler mode is set
461
461
case 'span' :
462
462
case undefined : {
463
463
DEBUG_BUILD && logger . log ( '[Profiling] Span profiler mode enabled.' ) ;
464
464
setupAutomatedSpanProfiling ( client ) ;
465
- break ;
465
+ return ;
466
466
}
467
467
default : {
468
468
DEBUG_BUILD && logger . warn ( `[Profiling] Unknown profiler mode: ${ mode } , profiler was not initialized` ) ;
469
469
}
470
470
}
471
471
}
472
+
473
+ else if ( profilingAPIVersion === 'current' ) {
474
+ DEBUG_BUILD && logger . log ( '[Profiling] Continuous profiler mode enabled.' ) ;
475
+ this . _profiler . initialize ( client ) ;
476
+ return ;
477
+ }
478
+
479
+ DEBUG_BUILD && logger . log ( [ '[Profiling] Profiling integration is added, but not enabled due to lack of SDK.init options.' ] )
480
+ return ;
472
481
} ,
473
482
} ;
474
483
} ) satisfies IntegrationFn ;
@@ -478,12 +487,17 @@ export const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> =
478
487
* @param options
479
488
* @returns 'legacy' if the options are using the legacy profiling API, 'current' if the options are using the current profiling API
480
489
*/
481
- function getProfilingMode ( options : NodeOptions ) : 'legacy' | 'current' {
490
+ function getProfilingMode ( options : NodeOptions ) : 'legacy' | 'current' | null {
482
491
if ( 'profilesSampleRate' in options || 'profilesSampler' in options ) {
483
492
return 'legacy' ;
484
493
}
485
494
486
- return 'current' ;
495
+ if ( 'profileSessionSampleRate' in options || 'profileLifecycle' in options ) {
496
+ return 'current' ;
497
+ }
498
+
499
+ // If neither are set, we are in the legacy continuous profiling mode
500
+ return 'legacy' ;
487
501
}
488
502
489
503
/**
0 commit comments