@@ -20,18 +20,15 @@ import {
20
20
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
21
21
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ,
22
22
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
23
- SentryNonRecordingSpan ,
24
23
TRACING_DEFAULTS ,
25
24
getActiveSpan ,
26
25
getCurrentScope ,
27
26
getDynamicSamplingContextFromSpan ,
28
27
getIsolationScope ,
29
- getTraceData ,
30
28
setCurrentClient ,
31
29
spanIsSampled ,
32
30
spanToJSON ,
33
31
startInactiveSpan ,
34
- updateSpanName ,
35
32
} from '@sentry/core' ;
36
33
import type { Span , StartSpanOptions } from '@sentry/core' ;
37
34
import { JSDOM } from 'jsdom' ;
@@ -268,10 +265,6 @@ describe('browserTracingIntegration', () => {
268
265
269
266
expect ( span ) . toBeDefined ( ) ;
270
267
expect ( spanIsSampled ( span ! ) ) . toBe ( false ) ;
271
-
272
- // Ensure getTraceData is correct in this case
273
- const traceData = getTraceData ( ) ;
274
- expect ( traceData [ 'sentry-trace' ] ) . toEqual ( `${ span ?. spanContext ( ) . traceId } -${ span ?. spanContext ( ) . spanId } -0` ) ;
275
268
} ) ;
276
269
277
270
it ( 'works with integration setup' , ( ) => {
@@ -372,7 +365,7 @@ describe('browserTracingIntegration', () => {
372
365
373
366
const client = new BrowserClient (
374
367
getDefaultBrowserClientOptions ( {
375
- tracesSampleRate : 1 ,
368
+ tracesSampleRate : 0 ,
376
369
integrations : [
377
370
browserTracingIntegration ( {
378
371
instrumentPageLoad : false ,
@@ -385,7 +378,9 @@ describe('browserTracingIntegration', () => {
385
378
setCurrentClient ( client ) ;
386
379
client . init ( ) ;
387
380
388
- const pageloadSpan = startBrowserTracingPageLoadSpan ( client , { name : 'test span' } ) ;
381
+ startBrowserTracingPageLoadSpan ( client , { name : 'test span' } ) ;
382
+
383
+ const pageloadSpan = getActiveSpan ( ) ;
389
384
390
385
expect ( spanToJSON ( pageloadSpan ! ) . op ) . toBe ( 'test op' ) ;
391
386
} ) ;
@@ -413,7 +408,7 @@ describe('browserTracingIntegration', () => {
413
408
414
409
const client = new BrowserClient (
415
410
getDefaultBrowserClientOptions ( {
416
- tracesSampleRate : 1 ,
411
+ tracesSampleRate : 0 ,
417
412
integrations : [
418
413
browserTracingIntegration ( {
419
414
instrumentPageLoad : false ,
@@ -463,10 +458,6 @@ describe('browserTracingIntegration', () => {
463
458
464
459
expect ( span ) . toBeDefined ( ) ;
465
460
expect ( spanIsSampled ( span ! ) ) . toBe ( false ) ;
466
-
467
- // Ensure getTraceData is correct in this case
468
- const traceData = getTraceData ( ) ;
469
- expect ( traceData [ 'sentry-trace' ] ) . toEqual ( `${ span ?. spanContext ( ) . traceId } -${ span ?. spanContext ( ) . spanId } -0` ) ;
470
461
} ) ;
471
462
472
463
it ( 'works with integration setup' , ( ) => {
@@ -571,7 +562,7 @@ describe('browserTracingIntegration', () => {
571
562
572
563
const client = new BrowserClient (
573
564
getDefaultBrowserClientOptions ( {
574
- tracesSampleRate : 1 ,
565
+ tracesSampleRate : 0 ,
575
566
integrations : [
576
567
browserTracingIntegration ( {
577
568
instrumentPageLoad : false ,
@@ -584,7 +575,9 @@ describe('browserTracingIntegration', () => {
584
575
setCurrentClient ( client ) ;
585
576
client . init ( ) ;
586
577
587
- const navigationSpan = startBrowserTracingNavigationSpan ( client , { name : 'test span' } ) ;
578
+ startBrowserTracingNavigationSpan ( client , { name : 'test span' } ) ;
579
+
580
+ const navigationSpan = getActiveSpan ( ) ;
588
581
589
582
expect ( spanToJSON ( navigationSpan ! ) . op ) . toBe ( 'test op' ) ;
590
583
} ) ;
@@ -597,7 +590,7 @@ describe('browserTracingIntegration', () => {
597
590
598
591
const client = new BrowserClient (
599
592
getDefaultBrowserClientOptions ( {
600
- tracesSampleRate : 1 ,
593
+ tracesSampleRate : 0 ,
601
594
integrations : [
602
595
browserTracingIntegration ( {
603
596
instrumentPageLoad : false ,
@@ -635,7 +628,7 @@ describe('browserTracingIntegration', () => {
635
628
it ( "updates the scopes' propagationContexts on a navigation" , ( ) => {
636
629
const client = new BrowserClient (
637
630
getDefaultBrowserClientOptions ( {
638
- integrations : [ browserTracingIntegration ( { instrumentPageLoad : false } ) ] ,
631
+ integrations : [ browserTracingIntegration ( ) ] ,
639
632
} ) ,
640
633
) ;
641
634
setCurrentClient ( client ) ;
@@ -644,8 +637,7 @@ describe('browserTracingIntegration', () => {
644
637
const oldIsolationScopePropCtx = getIsolationScope ( ) . getPropagationContext ( ) ;
645
638
const oldCurrentScopePropCtx = getCurrentScope ( ) . getPropagationContext ( ) ;
646
639
647
- const span = startBrowserTracingNavigationSpan ( client , { name : 'test navigation span' } ) ;
648
- const traceId = span ! . spanContext ( ) . traceId ;
640
+ startBrowserTracingNavigationSpan ( client , { name : 'test navigation span' } ) ;
649
641
650
642
const newIsolationScopePropCtx = getIsolationScope ( ) . getPropagationContext ( ) ;
651
643
const newCurrentScopePropCtx = getCurrentScope ( ) . getPropagationContext ( ) ;
@@ -657,37 +649,14 @@ describe('browserTracingIntegration', () => {
657
649
traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
658
650
} ) ;
659
651
expect ( newCurrentScopePropCtx ) . toEqual ( {
660
- traceId,
661
- sampled : false ,
662
- dsc : {
663
- environment : 'production' ,
664
- public_key : 'examplePublicKey' ,
665
- sample_rate : '0' ,
666
- trace_id : traceId ,
667
- } ,
652
+ traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
668
653
} ) ;
669
654
expect ( newIsolationScopePropCtx ) . toEqual ( {
670
655
traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
671
656
} ) ;
672
657
673
658
expect ( newIsolationScopePropCtx . traceId ) . not . toEqual ( oldIsolationScopePropCtx . traceId ) ;
674
659
expect ( newCurrentScopePropCtx . traceId ) . not . toEqual ( oldCurrentScopePropCtx . traceId ) ;
675
-
676
- const span2 = startBrowserTracingNavigationSpan ( client , { name : 'test navigation span 2' } ) ;
677
- const traceId2 = span2 ! . spanContext ( ) . traceId ;
678
- expect ( traceId2 ) . not . toEqual ( traceId ) ;
679
-
680
- const newCurrentScopePropCtx2 = getCurrentScope ( ) . getPropagationContext ( ) ;
681
- expect ( newCurrentScopePropCtx2 ) . toEqual ( {
682
- traceId : traceId2 ,
683
- sampled : false ,
684
- dsc : {
685
- environment : 'production' ,
686
- public_key : 'examplePublicKey' ,
687
- sample_rate : '0' ,
688
- trace_id : traceId2 ,
689
- } ,
690
- } ) ;
691
660
} ) ;
692
661
693
662
it ( "saves the span's positive sampling decision and its DSC on the propagationContext when the span finishes" , ( ) => {
@@ -708,18 +677,8 @@ describe('browserTracingIntegration', () => {
708
677
const propCtxBeforeEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
709
678
expect ( propCtxBeforeEnd ) . toStrictEqual ( {
710
679
traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
711
- sampled : true ,
712
- dsc : {
713
- environment : 'production' ,
714
- public_key : 'examplePublicKey' ,
715
- sample_rate : '1' ,
716
- sampled : 'true' ,
717
- transaction : 'mySpan' ,
718
- trace_id : propCtxBeforeEnd . traceId ,
719
- } ,
720
680
} ) ;
721
681
722
- updateSpanName ( navigationSpan ! , 'mySpan2' ) ;
723
682
navigationSpan ! . end ( ) ;
724
683
725
684
const propCtxAfterEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
@@ -731,7 +690,7 @@ describe('browserTracingIntegration', () => {
731
690
public_key : 'examplePublicKey' ,
732
691
sample_rate : '1' ,
733
692
sampled : 'true' ,
734
- transaction : 'mySpan2 ' ,
693
+ transaction : 'mySpan ' ,
735
694
trace_id : propCtxBeforeEnd . traceId ,
736
695
} ,
737
696
} ) ;
@@ -755,15 +714,6 @@ describe('browserTracingIntegration', () => {
755
714
const propCtxBeforeEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
756
715
expect ( propCtxBeforeEnd ) . toStrictEqual ( {
757
716
traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
758
- sampled : false ,
759
- dsc : {
760
- environment : 'production' ,
761
- public_key : 'examplePublicKey' ,
762
- sample_rate : '0' ,
763
- sampled : 'false' ,
764
- transaction : 'mySpan' ,
765
- trace_id : propCtxBeforeEnd . traceId ,
766
- } ,
767
717
} ) ;
768
718
769
719
navigationSpan ! . end ( ) ;
@@ -808,19 +758,18 @@ describe('browserTracingIntegration', () => {
808
758
const dynamicSamplingContext = getDynamicSamplingContextFromSpan ( idleSpan ! ) ;
809
759
const propagationContext = getCurrentScope ( ) . getPropagationContext ( ) ;
810
760
811
- // Span is non-recording
812
- expect ( idleSpan instanceof SentryNonRecordingSpan ) . toBe ( true ) ;
761
+ // Span is correct
762
+ expect ( spanToJSON ( idleSpan ) . op ) . toBe ( 'pageload' ) ;
763
+ expect ( spanToJSON ( idleSpan ) . trace_id ) . toEqual ( '12312012123120121231201212312012' ) ;
764
+ expect ( spanToJSON ( idleSpan ) . parent_span_id ) . toEqual ( '1121201211212012' ) ;
765
+ expect ( spanIsSampled ( idleSpan ) ) . toBe ( false ) ;
813
766
814
767
expect ( dynamicSamplingContext ) . toBeDefined ( ) ;
815
768
expect ( dynamicSamplingContext ) . toStrictEqual ( { release : '2.1.14' } ) ;
816
769
817
770
// Propagation context keeps the meta tag trace data for later events on the same route to add them to the trace
818
771
expect ( propagationContext . traceId ) . toEqual ( '12312012123120121231201212312012' ) ;
819
772
expect ( propagationContext . parentSpanId ) . toEqual ( '1121201211212012' ) ;
820
-
821
- // Ensure getTraceData is correct in this case
822
- const traceData = getTraceData ( ) ;
823
- expect ( traceData [ 'sentry-trace' ] ) . toMatch ( / 1 2 3 1 2 0 1 2 1 2 3 1 2 0 1 2 1 2 3 1 2 0 1 2 1 2 3 1 2 0 1 2 - [ a - f 0 - 9 ] { 16 } - 0 / ) ;
824
773
} ) ;
825
774
826
775
it ( 'puts frozen Dynamic Sampling Context on pageload span if sentry-trace data and only 3rd party baggage is present' , ( ) => {
@@ -846,19 +795,18 @@ describe('browserTracingIntegration', () => {
846
795
const dynamicSamplingContext = getDynamicSamplingContextFromSpan ( idleSpan ) ;
847
796
const propagationContext = getCurrentScope ( ) . getPropagationContext ( ) ;
848
797
849
- // Span is NonRecordingSpan
850
- expect ( idleSpan instanceof SentryNonRecordingSpan ) . toBe ( true ) ;
798
+ // Span is correct
799
+ expect ( spanToJSON ( idleSpan ) . op ) . toBe ( 'pageload' ) ;
800
+ expect ( spanToJSON ( idleSpan ) . trace_id ) . toEqual ( '12312012123120121231201212312012' ) ;
801
+ expect ( spanToJSON ( idleSpan ) . parent_span_id ) . toEqual ( '1121201211212012' ) ;
802
+ expect ( spanIsSampled ( idleSpan ) ) . toBe ( false ) ;
851
803
852
804
expect ( dynamicSamplingContext ) . toBeDefined ( ) ;
853
805
expect ( dynamicSamplingContext ) . toStrictEqual ( { } ) ;
854
806
855
807
// Propagation context keeps the meta tag trace data for later events on the same route to add them to the trace
856
808
expect ( propagationContext . traceId ) . toEqual ( '12312012123120121231201212312012' ) ;
857
809
expect ( propagationContext . parentSpanId ) . toEqual ( '1121201211212012' ) ;
858
-
859
- // Ensure getTraceData is correct in this case
860
- const traceData = getTraceData ( ) ;
861
- expect ( traceData [ 'sentry-trace' ] ) . toMatch ( / 1 2 3 1 2 0 1 2 1 2 3 1 2 0 1 2 1 2 3 1 2 0 1 2 1 2 3 1 2 0 1 2 - [ a - f 0 - 9 ] { 16 } - 0 / ) ;
862
810
} ) ;
863
811
864
812
it ( 'ignores the meta tag data for navigation spans' , ( ) => {
0 commit comments