@@ -12,7 +12,7 @@ const { expect } = require('chai');
12
12
const { fail } = expect ;
13
13
const supportedVersion = require ( '@instana/core' ) . tracing . supportedVersion ;
14
14
const config = require ( '@instana/core/test/config' ) ;
15
- const { retry, stringifyItems, delay } = require ( '@instana/core/test/test_util' ) ;
15
+ const { retry, stringifyItems, delay, expectAtLeastOneMatching } = require ( '@instana/core/test/test_util' ) ;
16
16
const ProcessControls = require ( '../../../../../test_util/ProcessControls' ) ;
17
17
const globalAgent = require ( '../../../../../globalAgent' ) ;
18
18
const {
@@ -342,6 +342,149 @@ function start(version, requestMethod, reducedTestSuite = false) {
342
342
} ) ;
343
343
} ) ;
344
344
345
+ describe ( 'ignore-endpoints:' , function ( ) {
346
+ describe ( 'when ignore-endpoints is enabled via agent configuration' , ( ) => {
347
+ const { AgentStubControls } = require ( '../../../../../apps/agentStubControls' ) ;
348
+ const customAgentControls = new AgentStubControls ( ) ;
349
+ let controls ;
350
+ const tableName = createTableName ( ) ;
351
+ before ( async ( ) => {
352
+ await customAgentControls . startAgent ( {
353
+ ignoreEndpoints : { dynamodb : [ 'listTables' ] }
354
+ } ) ;
355
+
356
+ controls = new ProcessControls ( {
357
+ agentControls : customAgentControls ,
358
+ appPath : path . join ( __dirname , './app' ) ,
359
+ env : {
360
+ AWS_DYNAMODB_TABLE_NAME : tableName ,
361
+ AWS_SDK_CLIENT_DYNAMODB_REQUIRE : version
362
+ }
363
+ } ) ;
364
+ await controls . startAndWaitForAgentConnection ( ) ;
365
+ } ) ;
366
+
367
+ beforeEach ( async ( ) => {
368
+ await customAgentControls . clearReceivedTraceData ( ) ;
369
+ } ) ;
370
+
371
+ after ( async ( ) => {
372
+ await customAgentControls . stopAgent ( ) ;
373
+ await controls . stop ( ) ;
374
+ } ) ;
375
+ after ( ( ) => cleanup ( tableName ) ) ;
376
+
377
+ it ( 'should ignore dynamodb spans for ignored endpoints (listTables)' , async ( ) => {
378
+ const apiPath = `/listTables/${ requestMethod } ` ;
379
+
380
+ await controls . sendRequest ( {
381
+ method : 'GET' ,
382
+ path : `${ apiPath } `
383
+ } ) ;
384
+ await delay ( 1000 ) ;
385
+ const spans = await customAgentControls . getSpans ( ) ;
386
+ // 1 x http entry span
387
+ // 1 x http client span
388
+ expect ( spans . length ) . to . equal ( 2 ) ;
389
+ spans . forEach ( span => {
390
+ expect ( span . n ) . not . to . equal ( 'dynamodb' ) ;
391
+ } ) ;
392
+ expectAtLeastOneMatching ( spans , [
393
+ span => expect ( span . n ) . to . equal ( 'node.http.server' ) ,
394
+ span => expect ( span . data . http . method ) . to . equal ( 'GET' )
395
+ ] ) ;
396
+ expectAtLeastOneMatching ( spans , [
397
+ span => expect ( span . n ) . to . equal ( 'node.http.client' ) ,
398
+ span => expect ( span . data . http . method ) . to . equal ( 'GET' )
399
+ ] ) ;
400
+ } ) ;
401
+ } ) ;
402
+ describe ( 'ignore-endpoints enabled via tracing config' , async ( ) => {
403
+ const tableName = createTableName ( ) ;
404
+ let appControls ;
405
+
406
+ before ( async ( ) => {
407
+ appControls = new ProcessControls ( {
408
+ useGlobalAgent : true ,
409
+ appPath : path . join ( __dirname , './app' ) ,
410
+ env : {
411
+ AWS_DYNAMODB_TABLE_NAME : tableName ,
412
+ AWS_SDK_CLIENT_DYNAMODB_REQUIRE : version ,
413
+ INSTANA_IGNORE_ENDPOINTS : 'dynamodb:listTables'
414
+ }
415
+ } ) ;
416
+ await appControls . startAndWaitForAgentConnection ( ) ;
417
+ } ) ;
418
+
419
+ beforeEach ( async ( ) => {
420
+ await agentControls . clearReceivedTraceData ( ) ;
421
+ } ) ;
422
+
423
+ after ( async ( ) => {
424
+ await appControls . stop ( ) ;
425
+ } ) ;
426
+
427
+ afterEach ( async ( ) => {
428
+ await appControls . clearIpcMessages ( ) ;
429
+ } ) ;
430
+
431
+ after ( ( ) => cleanup ( tableName ) ) ;
432
+
433
+ it ( 'should ignore spans for configured ignore endpoints(listTables)' , async function ( ) {
434
+ const apiPath = `/listTables/${ requestMethod } ` ;
435
+
436
+ await appControls . sendRequest ( {
437
+ method : 'GET' ,
438
+ path : `${ apiPath } `
439
+ } ) ;
440
+ await delay ( 1000 ) ;
441
+ const spans = await agentControls . getSpans ( ) ;
442
+ // 1 x http entry span
443
+ // 1 x http client span
444
+ expect ( spans . length ) . to . equal ( 2 ) ;
445
+ spans . forEach ( span => {
446
+ expect ( span . n ) . not . to . equal ( 'dynamodb' ) ;
447
+ } ) ;
448
+ expectAtLeastOneMatching ( spans , [
449
+ span => expect ( span . n ) . to . equal ( 'node.http.server' ) ,
450
+ span => expect ( span . data . http . method ) . to . equal ( 'GET' )
451
+ ] ) ;
452
+ expectAtLeastOneMatching ( spans , [
453
+ span => expect ( span . n ) . to . equal ( 'node.http.client' ) ,
454
+ span => expect ( span . data . http . method ) . to . equal ( 'GET' )
455
+ ] ) ;
456
+ } ) ;
457
+ it ( 'should not ignore spans for endpoints that are not in the ignore list' , async ( ) => {
458
+ const apiPath = `/createTable/${ requestMethod } ` ;
459
+
460
+ await appControls . sendRequest ( {
461
+ method : 'GET' ,
462
+ path : `${ apiPath } `
463
+ } ) ;
464
+ await delay ( 1000 ) ;
465
+ const spans = await agentControls . getSpans ( ) ;
466
+
467
+ // 1 x http entry span
468
+ // 1 x http client span
469
+ // 1 x dynamodb span
470
+ expect ( spans . length ) . to . equal ( 3 ) ;
471
+
472
+ expectAtLeastOneMatching ( spans , [
473
+ span => expect ( span . n ) . to . equal ( 'dynamodb' ) ,
474
+ span => expect ( span . data . dynamodb . op ) . to . equal ( 'createTable' )
475
+ ] ) ;
476
+ expectAtLeastOneMatching ( spans , [
477
+ span => expect ( span . n ) . to . equal ( 'node.http.server' ) ,
478
+ span => expect ( span . data . http . method ) . to . equal ( 'GET' )
479
+ ] ) ;
480
+ expectAtLeastOneMatching ( spans , [
481
+ span => expect ( span . n ) . to . equal ( 'node.http.client' ) ,
482
+ span => expect ( span . data . http . method ) . to . equal ( 'GET' )
483
+ ] ) ;
484
+ } ) ;
485
+ } ) ;
486
+ } ) ;
487
+
345
488
function verify ( controls , response , apiPath , operation , withError , tableName ) {
346
489
return retry (
347
490
( ) =>
0 commit comments