@@ -310,6 +310,7 @@ describe('Dynamic Instrumentation', function () {
310310 }
311311 } else if ( diagnostics . status === 'EMITTING' ) {
312312 const expected = expectedPayloads . get ( diagnostics . probeId )
313+ assert . ok ( expected , `expected payload not found for probe ${ diagnostics . probeId } ` )
313314 expectedPayloads . delete ( diagnostics . probeId )
314315 assertObjectContains ( event , expected )
315316 }
@@ -348,9 +349,52 @@ describe('Dynamic Instrumentation', function () {
348349 t . agent . addRemoteConfig ( rcConfig2 )
349350 } )
350351
351- it ( 'should support only triggering the probes whos conditions are met' , function ( done ) {
352+ it ( 'should only trigger the probes whos conditions are met (all have conditions) ' , function ( done ) {
352353 let installed = 0
353- const rcConfig1 = t . generateRemoteConfig ( { when : { json : { eq : [ { ref : 'foo' } , 'bar' ] } } } )
354+ const rcConfig1 = t . generateRemoteConfig ( {
355+ when : { json : { eq : [ { getmember : [ { getmember : [ { ref : 'request' } , 'params' ] } , 'name' ] } , 'invalid' ] } }
356+ } )
357+ const rcConfig2 = t . generateRemoteConfig ( {
358+ when : { json : { eq : [ { getmember : [ { getmember : [ { ref : 'request' } , 'params' ] } , 'name' ] } , 'bar' ] } }
359+ } )
360+ const expectedPayloads = new Map ( [
361+ [ rcConfig2 . config . id , {
362+ ddsource : 'dd_debugger' ,
363+ service : 'node' ,
364+ debugger : { diagnostics : { probeId : rcConfig2 . config . id , probeVersion : 0 , status : 'EMITTING' } }
365+ } ]
366+ ] )
367+
368+ t . agent . on ( 'debugger-diagnostics' , ( { payload } ) => {
369+ payload . forEach ( ( event ) => {
370+ const { diagnostics } = event . debugger
371+ if ( diagnostics . status === 'INSTALLED' ) {
372+ if ( ++ installed === 2 ) {
373+ t . axios . get ( t . breakpoint . url ) . catch ( done )
374+ }
375+ } else if ( diagnostics . status === 'EMITTING' ) {
376+ const expected = expectedPayloads . get ( diagnostics . probeId )
377+ assert . ok ( expected , `expected payload not found for probe ${ diagnostics . probeId } ` )
378+ expectedPayloads . delete ( diagnostics . probeId )
379+ assertObjectContains ( event , expected )
380+ }
381+ } )
382+ endIfDone ( )
383+ } )
384+
385+ t . agent . addRemoteConfig ( rcConfig1 )
386+ t . agent . addRemoteConfig ( rcConfig2 )
387+
388+ function endIfDone ( ) {
389+ if ( expectedPayloads . size === 0 ) done ( )
390+ }
391+ } )
392+
393+ it ( 'should only trigger the probes whos conditions are met (not all have conditions)' , function ( done ) {
394+ let installed = 0
395+ const rcConfig1 = t . generateRemoteConfig ( {
396+ when : { json : { eq : [ { getmember : [ { getmember : [ { ref : 'request' } , 'params' ] } , 'name' ] } , 'invalid' ] } }
397+ } )
354398 const rcConfig2 = t . generateRemoteConfig ( {
355399 when : { json : { eq : [ { getmember : [ { getmember : [ { ref : 'request' } , 'params' ] } , 'name' ] } , 'bar' ] } }
356400 } )
@@ -377,6 +421,7 @@ describe('Dynamic Instrumentation', function () {
377421 }
378422 } else if ( diagnostics . status === 'EMITTING' ) {
379423 const expected = expectedPayloads . get ( diagnostics . probeId )
424+ assert . ok ( expected , `expected payload not found for probe ${ diagnostics . probeId } ` )
380425 expectedPayloads . delete ( diagnostics . probeId )
381426 assertObjectContains ( event , expected )
382427 }
0 commit comments