@@ -325,6 +325,16 @@ describe('trace', () => {
325
325
expect ( getActiveSpan ( ) ) . toBe ( undefined ) ;
326
326
} ) ;
327
327
328
+ it ( 'allows to pass parentSpan=null' , ( ) => {
329
+ startSpan ( { name : 'GET users/[id' } , ( ) => {
330
+ startSpan ( { name : 'child' , parentSpan : null } , span => {
331
+ // Due to the way we propagate the scope in OTEL,
332
+ // the parent_span_id is not actually undefined here, but comes from the propagation context
333
+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
334
+ } ) ;
335
+ } ) ;
336
+ } ) ;
337
+
328
338
it ( 'allows to force a transaction with forceTransaction=true' , async ( ) => {
329
339
const client = getClient ( ) ! ;
330
340
const transactionEvents : Event [ ] = [ ] ;
@@ -577,6 +587,17 @@ describe('trace', () => {
577
587
expect ( getActiveSpan ( ) ) . toBe ( undefined ) ;
578
588
} ) ;
579
589
590
+ it ( 'allows to pass parentSpan=null' , ( ) => {
591
+ startSpan ( { name : 'outer' } , ( ) => {
592
+ const span = startInactiveSpan ( { name : 'test span' , parentSpan : null } ) ;
593
+
594
+ // Due to the way we propagate the scope in OTEL,
595
+ // the parent_span_id is not actually undefined here, but comes from the propagation context
596
+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
597
+ span . end ( ) ;
598
+ } ) ;
599
+ } ) ;
600
+
580
601
it ( 'allows to force a transaction with forceTransaction=true' , async ( ) => {
581
602
const client = getClient ( ) ! ;
582
603
const transactionEvents : Event [ ] = [ ] ;
@@ -856,6 +877,17 @@ describe('trace', () => {
856
877
expect ( getActiveSpan ( ) ) . toBe ( undefined ) ;
857
878
} ) ;
858
879
880
+ it ( 'allows to pass parentSpan=null' , ( ) => {
881
+ startSpan ( { name : 'outer' } , ( ) => {
882
+ startSpanManual ( { name : 'GET users/[id]' , parentSpan : null } , span => {
883
+ // Due to the way we propagate the scope in OTEL,
884
+ // the parent_span_id is not actually undefined here, but comes from the propagation context
885
+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
886
+ span . end ( ) ;
887
+ } ) ;
888
+ } ) ;
889
+ } ) ;
890
+
859
891
it ( 'allows to force a transaction with forceTransaction=true' , async ( ) => {
860
892
const client = getClient ( ) ! ;
861
893
const transactionEvents : Event [ ] = [ ] ;
0 commit comments