@@ -329,9 +329,7 @@ describe('trace', () => {
329
329
it ( 'allows to pass parentSpan=null' , ( ) => {
330
330
startSpan ( { name : 'GET users/[id' } , ( ) => {
331
331
startSpan ( { name : 'child' , parentSpan : null } , span => {
332
- // Due to the way we propagate the scope in OTEL,
333
- // the parent_span_id is not actually undefined here, but comes from the propagation context
334
- expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
332
+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( undefined ) ;
335
333
} ) ;
336
334
} ) ;
337
335
} ) ;
@@ -591,10 +589,7 @@ describe('trace', () => {
591
589
it ( 'allows to pass parentSpan=null' , ( ) => {
592
590
startSpan ( { name : 'outer' } , ( ) => {
593
591
const span = startInactiveSpan ( { name : 'test span' , parentSpan : null } ) ;
594
-
595
- // Due to the way we propagate the scope in OTEL,
596
- // the parent_span_id is not actually undefined here, but comes from the propagation context
597
- expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
592
+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( undefined ) ;
598
593
span . end ( ) ;
599
594
} ) ;
600
595
} ) ;
@@ -881,9 +876,7 @@ describe('trace', () => {
881
876
it ( 'allows to pass parentSpan=null' , ( ) => {
882
877
startSpan ( { name : 'outer' } , ( ) => {
883
878
startSpanManual ( { name : 'GET users/[id]' , parentSpan : null } , span => {
884
- // Due to the way we propagate the scope in OTEL,
885
- // the parent_span_id is not actually undefined here, but comes from the propagation context
886
- expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( getCurrentScope ( ) . getPropagationContext ( ) . spanId ) ;
879
+ expect ( spanToJSON ( span ) . parent_span_id ) . toBe ( undefined ) ;
887
880
span . end ( ) ;
888
881
} ) ;
889
882
} ) ;
@@ -1016,20 +1009,23 @@ describe('trace', () => {
1016
1009
} ) ;
1017
1010
1018
1011
describe ( 'propagation' , ( ) => {
1019
- it ( 'picks up the trace context from the scope, if there is no parent' , ( ) => {
1012
+ it ( 'ignores the trace context from the scope, if there is no parent & no propagationContext.parentSpanId ' , ( ) => {
1020
1013
withScope ( scope => {
1021
1014
const propagationContext = scope . getPropagationContext ( ) ;
1022
1015
const span = startInactiveSpan ( { name : 'test span' } ) ;
1023
1016
1024
1017
expect ( span ) . toBeDefined ( ) ;
1025
- expect ( spanToJSON ( span ) . trace_id ) . toEqual ( propagationContext . traceId ) ;
1026
- expect ( spanToJSON ( span ) . parent_span_id ) . toEqual ( propagationContext . spanId ) ;
1018
+ expect ( spanToJSON ( span ) . trace_id ) . toMatch ( / ^ [ 0 - 9 a - f ] { 32 } $ / ) ;
1019
+ expect ( spanToJSON ( span ) . trace_id ) . not . toEqual ( propagationContext . traceId ) ;
1020
+ expect ( spanToJSON ( span ) . parent_span_id ) . toEqual ( undefined ) ;
1027
1021
1028
1022
expect ( getDynamicSamplingContextFromSpan ( span ) ) . toEqual ( {
1029
- ...getDynamicSamplingContextFromClient ( propagationContext . traceId , getClient ( ) ! ) ,
1023
+ environment : 'production' ,
1024
+ public_key : 'username' ,
1030
1025
sample_rate : '1' ,
1031
1026
sampled : 'true' ,
1032
1027
transaction : 'test span' ,
1028
+ trace_id : spanToJSON ( span ) . trace_id ,
1033
1029
} ) ;
1034
1030
} ) ;
1035
1031
} ) ;
0 commit comments