@@ -459,27 +459,36 @@ describe('ChildProcessTracker', function () {
459459 assert . strictEqual ( tracker . size , 0 , 'expected tracker to be empty' )
460460 } )
461461
462- it ( 'logs a warning message when system usage exceeds threshold' , async function ( ) {
462+ it ( 'logs a warning message and emits metric when cpu exceeds threshold' , async function ( ) {
463463 const runningProcess = startSleepProcess ( )
464464 tracker . add ( runningProcess . childProcess )
465465
466466 const highCpu : ProcessStats = {
467467 cpu : ChildProcessTracker . thresholds . cpu + 1 ,
468468 memory : 0 ,
469469 }
470- const highMemory : ProcessStats = {
471- cpu : 0 ,
472- memory : ChildProcessTracker . thresholds . memory + 1 ,
473- }
474470
475471 usageMock . resolves ( highCpu )
476472
477473 await clock . tickAsync ( ChildProcessTracker . pollingInterval )
478474 assertLogsContain ( 'exceeded cpu threshold' , false , 'warn' )
475+ assertTelemetry ( 'ide_childProcessWarning' , { systemResource : 'cpu' } )
476+
477+ await stopAndWait ( runningProcess )
478+ } )
479+
480+ it ( 'logs a warning message and emits metric when memory exceeds threshold' , async function ( ) {
481+ const runningProcess = startSleepProcess ( )
482+ tracker . add ( runningProcess . childProcess )
483+ const highMemory : ProcessStats = {
484+ cpu : 0 ,
485+ memory : ChildProcessTracker . thresholds . memory + 1 ,
486+ }
479487
480488 usageMock . resolves ( highMemory )
481489 await clock . tickAsync ( ChildProcessTracker . pollingInterval )
482490 assertLogsContain ( 'exceeded memory threshold' , false , 'warn' )
491+ assertTelemetry ( 'ide_childProcessWarning' , { systemResource : 'memory' } )
483492
484493 await stopAndWait ( runningProcess )
485494 } )
@@ -510,12 +519,13 @@ describe('ChildProcessTracker', function () {
510519 await clock . tickAsync ( ChildProcessTracker . pollingInterval )
511520
512521 assert . throws ( ( ) => assertLogsContain ( runningProcess . childProcess . pid ( ) . toString ( ) , false , 'warn' ) )
513-
522+ assert . throws ( ( ) => assertTelemetry ( 'ide_childProcessWarning' , { } ) )
514523 await stopAndWait ( runningProcess )
515524 } )
516525 } )
517526
518527 it ( 'logAllUsage includes only active processes' , async function ( ) {
528+ console . log ( 'start' )
519529 const runningProcess1 = startSleepProcess ( )
520530 const runningProcess2 = startSleepProcess ( )
521531
@@ -528,9 +538,10 @@ describe('ChildProcessTracker', function () {
528538 await stopAndWait ( runningProcess1 )
529539
530540 await tracker . logAllUsage ( )
531-
541+ console . log ( 'logAllUsage called' )
532542 assert . throws ( ( ) => assertLogsContain ( runningProcess1 . childProcess . pid ( ) . toString ( ) , false , 'info' ) )
533543 assertLogsContain ( runningProcess2 . childProcess . pid ( ) . toString ( ) , false , 'info' )
544+ console . log ( 'end' )
534545 } )
535546
536547 it ( 'logAllUsage defaults to empty message when empty' , async function ( ) {
0 commit comments