File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
plugins/node/opentelemetry-instrumentation-mongodb/test Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -669,6 +669,49 @@ describe('MongoDBInstrumentation-Tracing-v3', () => {
669669 } ) ;
670670 } ) ;
671671
672+ describe ( 'requireParentSpan' , ( ) => {
673+ // Resetting the behavior to default to avoid flakes in other tests
674+ beforeEach ( ( ) => {
675+ instrumentation . setConfig ( ) ;
676+ } ) ;
677+
678+ afterEach ( ( ) => {
679+ instrumentation . setConfig ( ) ;
680+ } ) ;
681+
682+ it ( 'should not create spans without parent span when requireParentSpan is explicitly set to true' , done => {
683+ context . with ( trace . deleteSpan ( context . active ( ) ) , ( ) => {
684+ collection
685+ . insertOne ( { a : 1 } )
686+ . then ( ( ) => {
687+ assert . strictEqual ( getTestSpans ( ) . length , 0 ) ;
688+ done ( ) ;
689+ } )
690+ . catch ( err => {
691+ done ( err ) ;
692+ } ) ;
693+ } ) ;
694+ } ) ;
695+
696+ it ( 'should create spans without parent span when requireParentSpan is false' , done => {
697+ instrumentation . setConfig ( {
698+ requireParentSpan : false ,
699+ } ) ;
700+
701+ context . with ( trace . deleteSpan ( context . active ( ) ) , ( ) => {
702+ collection
703+ . insertOne ( { a : 1 } )
704+ . then ( ( ) => {
705+ assert . strictEqual ( getTestSpans ( ) . length , 1 ) ;
706+ done ( ) ;
707+ } )
708+ . catch ( err => {
709+ done ( err ) ;
710+ } ) ;
711+ } ) ;
712+ } ) ;
713+ } ) ;
714+
672715 /** Should intercept command */
673716 describe ( 'Removing Instrumentation' , ( ) => {
674717 it ( 'should unpatch plugin' , ( ) => {
You can’t perform that action at this time.
0 commit comments