@@ -20,18 +20,15 @@ import {
2020 SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
2121 SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ,
2222 SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
23- SentryNonRecordingSpan ,
2423 TRACING_DEFAULTS ,
2524 getActiveSpan ,
2625 getCurrentScope ,
2726 getDynamicSamplingContextFromSpan ,
2827 getIsolationScope ,
29- getTraceData ,
3028 setCurrentClient ,
3129 spanIsSampled ,
3230 spanToJSON ,
3331 startInactiveSpan ,
34- updateSpanName ,
3532} from '@sentry/core' ;
3633import type { Span , StartSpanOptions } from '@sentry/core' ;
3734import { JSDOM } from 'jsdom' ;
@@ -268,10 +265,6 @@ describe('browserTracingIntegration', () => {
268265
269266 expect ( span ) . toBeDefined ( ) ;
270267 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` ) ;
275268 } ) ;
276269
277270 it ( 'works with integration setup' , ( ) => {
@@ -372,7 +365,7 @@ describe('browserTracingIntegration', () => {
372365
373366 const client = new BrowserClient (
374367 getDefaultBrowserClientOptions ( {
375- tracesSampleRate : 1 ,
368+ tracesSampleRate : 0 ,
376369 integrations : [
377370 browserTracingIntegration ( {
378371 instrumentPageLoad : false ,
@@ -385,7 +378,9 @@ describe('browserTracingIntegration', () => {
385378 setCurrentClient ( client ) ;
386379 client . init ( ) ;
387380
388- const pageloadSpan = startBrowserTracingPageLoadSpan ( client , { name : 'test span' } ) ;
381+ startBrowserTracingPageLoadSpan ( client , { name : 'test span' } ) ;
382+
383+ const pageloadSpan = getActiveSpan ( ) ;
389384
390385 expect ( spanToJSON ( pageloadSpan ! ) . op ) . toBe ( 'test op' ) ;
391386 } ) ;
@@ -413,7 +408,7 @@ describe('browserTracingIntegration', () => {
413408
414409 const client = new BrowserClient (
415410 getDefaultBrowserClientOptions ( {
416- tracesSampleRate : 1 ,
411+ tracesSampleRate : 0 ,
417412 integrations : [
418413 browserTracingIntegration ( {
419414 instrumentPageLoad : false ,
@@ -463,10 +458,6 @@ describe('browserTracingIntegration', () => {
463458
464459 expect ( span ) . toBeDefined ( ) ;
465460 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` ) ;
470461 } ) ;
471462
472463 it ( 'works with integration setup' , ( ) => {
@@ -571,7 +562,7 @@ describe('browserTracingIntegration', () => {
571562
572563 const client = new BrowserClient (
573564 getDefaultBrowserClientOptions ( {
574- tracesSampleRate : 1 ,
565+ tracesSampleRate : 0 ,
575566 integrations : [
576567 browserTracingIntegration ( {
577568 instrumentPageLoad : false ,
@@ -584,7 +575,9 @@ describe('browserTracingIntegration', () => {
584575 setCurrentClient ( client ) ;
585576 client . init ( ) ;
586577
587- const navigationSpan = startBrowserTracingNavigationSpan ( client , { name : 'test span' } ) ;
578+ startBrowserTracingNavigationSpan ( client , { name : 'test span' } ) ;
579+
580+ const navigationSpan = getActiveSpan ( ) ;
588581
589582 expect ( spanToJSON ( navigationSpan ! ) . op ) . toBe ( 'test op' ) ;
590583 } ) ;
@@ -597,7 +590,7 @@ describe('browserTracingIntegration', () => {
597590
598591 const client = new BrowserClient (
599592 getDefaultBrowserClientOptions ( {
600- tracesSampleRate : 1 ,
593+ tracesSampleRate : 0 ,
601594 integrations : [
602595 browserTracingIntegration ( {
603596 instrumentPageLoad : false ,
@@ -635,7 +628,7 @@ describe('browserTracingIntegration', () => {
635628 it ( "updates the scopes' propagationContexts on a navigation" , ( ) => {
636629 const client = new BrowserClient (
637630 getDefaultBrowserClientOptions ( {
638- integrations : [ browserTracingIntegration ( { instrumentPageLoad : false } ) ] ,
631+ integrations : [ browserTracingIntegration ( ) ] ,
639632 } ) ,
640633 ) ;
641634 setCurrentClient ( client ) ;
@@ -644,8 +637,7 @@ describe('browserTracingIntegration', () => {
644637 const oldIsolationScopePropCtx = getIsolationScope ( ) . getPropagationContext ( ) ;
645638 const oldCurrentScopePropCtx = getCurrentScope ( ) . getPropagationContext ( ) ;
646639
647- const span = startBrowserTracingNavigationSpan ( client , { name : 'test navigation span' } ) ;
648- const traceId = span ! . spanContext ( ) . traceId ;
640+ startBrowserTracingNavigationSpan ( client , { name : 'test navigation span' } ) ;
649641
650642 const newIsolationScopePropCtx = getIsolationScope ( ) . getPropagationContext ( ) ;
651643 const newCurrentScopePropCtx = getCurrentScope ( ) . getPropagationContext ( ) ;
@@ -657,37 +649,14 @@ describe('browserTracingIntegration', () => {
657649 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
658650 } ) ;
659651 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 } / ) ,
668653 } ) ;
669654 expect ( newIsolationScopePropCtx ) . toEqual ( {
670655 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
671656 } ) ;
672657
673658 expect ( newIsolationScopePropCtx . traceId ) . not . toEqual ( oldIsolationScopePropCtx . traceId ) ;
674659 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- } ) ;
691660 } ) ;
692661
693662 it ( "saves the span's positive sampling decision and its DSC on the propagationContext when the span finishes" , ( ) => {
@@ -708,18 +677,8 @@ describe('browserTracingIntegration', () => {
708677 const propCtxBeforeEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
709678 expect ( propCtxBeforeEnd ) . toStrictEqual ( {
710679 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- } ,
720680 } ) ;
721681
722- updateSpanName ( navigationSpan ! , 'mySpan2' ) ;
723682 navigationSpan ! . end ( ) ;
724683
725684 const propCtxAfterEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
@@ -731,7 +690,7 @@ describe('browserTracingIntegration', () => {
731690 public_key : 'examplePublicKey' ,
732691 sample_rate : '1' ,
733692 sampled : 'true' ,
734- transaction : 'mySpan2 ' ,
693+ transaction : 'mySpan ' ,
735694 trace_id : propCtxBeforeEnd . traceId ,
736695 } ,
737696 } ) ;
@@ -755,15 +714,6 @@ describe('browserTracingIntegration', () => {
755714 const propCtxBeforeEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
756715 expect ( propCtxBeforeEnd ) . toStrictEqual ( {
757716 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- } ,
767717 } ) ;
768718
769719 navigationSpan ! . end ( ) ;
@@ -808,19 +758,18 @@ describe('browserTracingIntegration', () => {
808758 const dynamicSamplingContext = getDynamicSamplingContextFromSpan ( idleSpan ! ) ;
809759 const propagationContext = getCurrentScope ( ) . getPropagationContext ( ) ;
810760
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 ) ;
813766
814767 expect ( dynamicSamplingContext ) . toBeDefined ( ) ;
815768 expect ( dynamicSamplingContext ) . toStrictEqual ( { release : '2.1.14' } ) ;
816769
817770 // Propagation context keeps the meta tag trace data for later events on the same route to add them to the trace
818771 expect ( propagationContext . traceId ) . toEqual ( '12312012123120121231201212312012' ) ;
819772 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 / ) ;
824773 } ) ;
825774
826775 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', () => {
846795 const dynamicSamplingContext = getDynamicSamplingContextFromSpan ( idleSpan ) ;
847796 const propagationContext = getCurrentScope ( ) . getPropagationContext ( ) ;
848797
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 ) ;
851803
852804 expect ( dynamicSamplingContext ) . toBeDefined ( ) ;
853805 expect ( dynamicSamplingContext ) . toStrictEqual ( { } ) ;
854806
855807 // Propagation context keeps the meta tag trace data for later events on the same route to add them to the trace
856808 expect ( propagationContext . traceId ) . toEqual ( '12312012123120121231201212312012' ) ;
857809 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 / ) ;
862810 } ) ;
863811
864812 it ( 'ignores the meta tag data for navigation spans' , ( ) => {
0 commit comments