@@ -51,6 +51,7 @@ describe('Plugin', () => {
5151 let db
5252 let BSON
5353 let startSpy
54+ let injectCommentSpy
5455 let usesDelete
5556
5657 describe ( 'mongodb-core' , ( ) => {
@@ -564,9 +565,7 @@ describe('Plugin', () => {
564565
565566 describe ( 'with dbmPropagationMode full' , ( ) => {
566567 before ( ( ) => {
567- return agent . load ( 'mongodb-core' , {
568- dbmPropagationMode : 'full'
569- } )
568+ return agent . load ( 'mongodb-core' , { dbmPropagationMode : 'full' } )
570569 } )
571570
572571 after ( ( ) => {
@@ -579,21 +578,25 @@ describe('Plugin', () => {
579578 collection = db . collection ( collectionName )
580579
581580 startSpy = sinon . spy ( MongodbCorePlugin . prototype , 'start' )
581+ injectCommentSpy = sinon . spy ( MongodbCorePlugin . prototype , 'injectDbmComment' )
582582 } )
583583
584584 afterEach ( ( ) => {
585585 startSpy ?. restore ( )
586+ injectCommentSpy ?. restore ( )
586587 } )
587588
588589 it ( 'DBM propagation should inject full mode with traceparent as comment' , done => {
589590 agent
590- . assertSomeTraces ( traces => {
591- const span = traces [ 0 ] [ 0 ]
591+ . assertFirstTraceSpan ( span => {
592592 const traceId = span . meta [ '_dd.p.tid' ] + span . trace_id . toString ( 16 ) . padStart ( 16 , '0' )
593593 const spanId = span . span_id . toString ( 16 ) . padStart ( 16 , '0' )
594+ const samplingPriotrity = span . metrics . _sampling_priority_v1 > 0 ? '01' : '00'
594595
595596 assert . strictEqual ( startSpy . called , true )
596- const { comment } = startSpy . getCall ( 0 ) . args [ 0 ] . ops
597+ assert . strictEqual ( injectCommentSpy . called , true )
598+
599+ const comment = injectCommentSpy . getCall ( 0 ) . returnValue
597600 assert . strictEqual ( comment ,
598601 `dddb='${ encodeURIComponent ( span . meta [ 'db.name' ] ) } ',` +
599602 'dddbs=\'test-mongodb\',' +
@@ -602,7 +605,7 @@ describe('Plugin', () => {
602605 `ddps='${ encodeURIComponent ( span . meta . service ) } ',` +
603606 `ddpv='${ ddpv } ',` +
604607 `ddprs='${ encodeURIComponent ( span . meta [ 'peer.service' ] ) } ',` +
605- `traceparent='00-${ traceId } -${ spanId } -01 '`
608+ `traceparent='00-${ traceId } -${ spanId } -${ samplingPriotrity } '`
606609 )
607610 } )
608611 . then ( done )
0 commit comments