Skip to content

Commit b4d8488

Browse files
committed
profiling: fix tests
1 parent 3d4942b commit b4d8488

File tree

3 files changed

+598
-564
lines changed

3 files changed

+598
-564
lines changed

packages/profiling-node/src/integration.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,30 +445,39 @@ export const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> =
445445
setup(client: NodeClient) {
446446
DEBUG_BUILD && logger.log('[Profiling] Profiling integration setup.');
447447
const options = client.getOptions();
448-
449448
const profilingAPIVersion = getProfilingMode(options);
450449

450+
451451
if (profilingAPIVersion === 'legacy') {
452-
const mode = !('profileSessionSampleRate' in options) && !options.profilesSampler ? 'continuous' : 'span';
452+
const mode = ('profilesSampleRate' in options || 'profilesSampler' in options) ? 'span' : 'continuous';
453453

454454
switch (mode) {
455455
case 'continuous': {
456456
DEBUG_BUILD && logger.log('[Profiling] Continuous profiler mode enabled.');
457457
this._profiler.initialize(client);
458-
break;
458+
return;
459459
}
460460
// Default to span profiling when no mode profiler mode is set
461461
case 'span':
462462
case undefined: {
463463
DEBUG_BUILD && logger.log('[Profiling] Span profiler mode enabled.');
464464
setupAutomatedSpanProfiling(client);
465-
break;
465+
return;
466466
}
467467
default: {
468468
DEBUG_BUILD && logger.warn(`[Profiling] Unknown profiler mode: ${mode}, profiler was not initialized`);
469469
}
470470
}
471471
}
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;
472481
},
473482
};
474483
}) satisfies IntegrationFn;
@@ -478,12 +487,17 @@ export const _nodeProfilingIntegration = ((): ProfilingIntegration<NodeClient> =
478487
* @param options
479488
* @returns 'legacy' if the options are using the legacy profiling API, 'current' if the options are using the current profiling API
480489
*/
481-
function getProfilingMode(options: NodeOptions): 'legacy' | 'current' {
490+
function getProfilingMode(options: NodeOptions): 'legacy' | 'current' | null {
482491
if ('profilesSampleRate' in options || 'profilesSampler' in options) {
483492
return 'legacy';
484493
}
485494

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';
487501
}
488502

489503
/**

0 commit comments

Comments
 (0)