@@ -558,6 +558,32 @@ describe('trace', () => {
558558 expect ( isSpan ( span ) ) . toBe ( true ) ;
559559 expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
560560 } ) ;
561+
562+ it ( 'does not record no_parent_span client report when onlyIfParent is not set' , ( ) => {
563+ const client = getClient ( ) ! ;
564+ const spyOnDroppedEvent = vi . spyOn ( client , 'recordDroppedEvent' ) ;
565+
566+ context . with ( ROOT_CONTEXT , ( ) => {
567+ startSpan ( { name : 'root span without onlyIfParent' } , span => {
568+ return span ;
569+ } ) ;
570+ } ) ;
571+
572+ expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
573+ } ) ;
574+
575+ it ( 'does not record no_parent_span client report when onlyIfParent is false even without a parent' , ( ) => {
576+ const client = getClient ( ) ! ;
577+ const spyOnDroppedEvent = vi . spyOn ( client , 'recordDroppedEvent' ) ;
578+
579+ context . with ( ROOT_CONTEXT , ( ) => {
580+ startSpan ( { name : 'root span' , onlyIfParent : false } , span => {
581+ return span ;
582+ } ) ;
583+ } ) ;
584+
585+ expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
586+ } ) ;
561587 } ) ;
562588 } ) ;
563589
@@ -857,6 +883,30 @@ describe('trace', () => {
857883 expect ( isSpan ( span ) ) . toBe ( true ) ;
858884 expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
859885 } ) ;
886+
887+ it ( 'does not record no_parent_span client report when onlyIfParent is not set' , ( ) => {
888+ const client = getClient ( ) ! ;
889+ const spyOnDroppedEvent = vi . spyOn ( client , 'recordDroppedEvent' ) ;
890+
891+ context . with ( ROOT_CONTEXT , ( ) => {
892+ const span = startInactiveSpan ( { name : 'root span without onlyIfParent' } ) ;
893+ span . end ( ) ;
894+ } ) ;
895+
896+ expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
897+ } ) ;
898+
899+ it ( 'does not record no_parent_span client report when onlyIfParent is false even without a parent' , ( ) => {
900+ const client = getClient ( ) ! ;
901+ const spyOnDroppedEvent = vi . spyOn ( client , 'recordDroppedEvent' ) ;
902+
903+ context . with ( ROOT_CONTEXT , ( ) => {
904+ const span = startInactiveSpan ( { name : 'root span' , onlyIfParent : false } ) ;
905+ span . end ( ) ;
906+ } ) ;
907+
908+ expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
909+ } ) ;
860910 } ) ;
861911
862912 it ( 'includes the scope at the time the span was started when finished' , async ( ) => {
@@ -1238,6 +1288,34 @@ describe('trace', () => {
12381288 expect ( isSpan ( span ) ) . toBe ( true ) ;
12391289 expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
12401290 } ) ;
1291+
1292+ it ( 'does not record no_parent_span client report when onlyIfParent is not set' , ( ) => {
1293+ const client = getClient ( ) ! ;
1294+ const spyOnDroppedEvent = vi . spyOn ( client , 'recordDroppedEvent' ) ;
1295+
1296+ context . with ( ROOT_CONTEXT , ( ) => {
1297+ startSpanManual ( { name : 'root span without onlyIfParent' } , span => {
1298+ span . end ( ) ;
1299+ return span ;
1300+ } ) ;
1301+ } ) ;
1302+
1303+ expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
1304+ } ) ;
1305+
1306+ it ( 'does not record no_parent_span client report when onlyIfParent is false even without a parent' , ( ) => {
1307+ const client = getClient ( ) ! ;
1308+ const spyOnDroppedEvent = vi . spyOn ( client , 'recordDroppedEvent' ) ;
1309+
1310+ context . with ( ROOT_CONTEXT , ( ) => {
1311+ startSpanManual ( { name : 'root span' , onlyIfParent : false } , span => {
1312+ span . end ( ) ;
1313+ return span ;
1314+ } ) ;
1315+ } ) ;
1316+
1317+ expect ( spyOnDroppedEvent ) . not . toHaveBeenCalledWith ( 'no_parent_span' , 'span' ) ;
1318+ } ) ;
12411319 } ) ;
12421320 } ) ;
12431321
0 commit comments