@@ -644,15 +644,19 @@ describe('browserTracingIntegration', () => {
644644
645645 expect ( oldCurrentScopePropCtx ) . toEqual ( {
646646 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
647+ sampleRand : expect . any ( Number ) ,
647648 } ) ;
648649 expect ( oldIsolationScopePropCtx ) . toEqual ( {
649650 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
651+ sampleRand : expect . any ( Number ) ,
650652 } ) ;
651653 expect ( newCurrentScopePropCtx ) . toEqual ( {
652654 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
655+ sampleRand : expect . any ( Number ) ,
653656 } ) ;
654657 expect ( newIsolationScopePropCtx ) . toEqual ( {
655658 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
659+ sampleRand : expect . any ( Number ) ,
656660 } ) ;
657661
658662 expect ( newIsolationScopePropCtx . traceId ) . not . toEqual ( oldIsolationScopePropCtx . traceId ) ;
@@ -676,6 +680,7 @@ describe('browserTracingIntegration', () => {
676680
677681 const propCtxBeforeEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
678682 expect ( propCtxBeforeEnd ) . toStrictEqual ( {
683+ sampleRand : expect . any ( Number ) ,
679684 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
680685 } ) ;
681686
@@ -685,13 +690,15 @@ describe('browserTracingIntegration', () => {
685690 expect ( propCtxAfterEnd ) . toStrictEqual ( {
686691 traceId : propCtxBeforeEnd . traceId ,
687692 sampled : true ,
693+ sampleRand : expect . any ( Number ) ,
688694 dsc : {
689695 environment : 'production' ,
690696 public_key : 'examplePublicKey' ,
691697 sample_rate : '1' ,
692698 sampled : 'true' ,
693699 transaction : 'mySpan' ,
694700 trace_id : propCtxBeforeEnd . traceId ,
701+ sample_rand : expect . any ( String ) ,
695702 } ,
696703 } ) ;
697704 } ) ;
@@ -714,6 +721,7 @@ describe('browserTracingIntegration', () => {
714721 const propCtxBeforeEnd = getCurrentScope ( ) . getPropagationContext ( ) ;
715722 expect ( propCtxBeforeEnd ) . toStrictEqual ( {
716723 traceId : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
724+ sampleRand : expect . any ( Number ) ,
717725 } ) ;
718726
719727 navigationSpan ! . end ( ) ;
@@ -722,13 +730,15 @@ describe('browserTracingIntegration', () => {
722730 expect ( propCtxAfterEnd ) . toStrictEqual ( {
723731 traceId : propCtxBeforeEnd . traceId ,
724732 sampled : false ,
733+ sampleRand : expect . any ( Number ) ,
725734 dsc : {
726735 environment : 'production' ,
727736 public_key : 'examplePublicKey' ,
728737 sample_rate : '0' ,
729738 sampled : 'false' ,
730739 transaction : 'mySpan' ,
731740 trace_id : propCtxBeforeEnd . traceId ,
741+ sample_rand : expect . any ( String ) ,
732742 } ,
733743 } ) ;
734744 } ) ;
@@ -739,7 +749,7 @@ describe('browserTracingIntegration', () => {
739749 // make sampled false here, so we can see that it's being used rather than the tracesSampleRate-dictated one
740750 document . head . innerHTML =
741751 '<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-0">' +
742- '<meta name="baggage" content="sentry-release=2.1.14,foo=bar">' ;
752+ '<meta name="baggage" content="sentry-release=2.1.14,foo=bar,sentry-sample_rand=0.123 ">' ;
743753
744754 const client = new BrowserClient (
745755 getDefaultBrowserClientOptions ( {
@@ -765,11 +775,12 @@ describe('browserTracingIntegration', () => {
765775 expect ( spanIsSampled ( idleSpan ) ) . toBe ( false ) ;
766776
767777 expect ( dynamicSamplingContext ) . toBeDefined ( ) ;
768- expect ( dynamicSamplingContext ) . toStrictEqual ( { release : '2.1.14' } ) ;
778+ expect ( dynamicSamplingContext ) . toStrictEqual ( { release : '2.1.14' , sample_rand : '0.123' } ) ;
769779
770780 // Propagation context keeps the meta tag trace data for later events on the same route to add them to the trace
771781 expect ( propagationContext . traceId ) . toEqual ( '12312012123120121231201212312012' ) ;
772782 expect ( propagationContext . parentSpanId ) . toEqual ( '1121201211212012' ) ;
783+ expect ( propagationContext . sampleRand ) . toBe ( 0.123 ) ;
773784 } ) ;
774785
775786 it ( 'puts frozen Dynamic Sampling Context on pageload span if sentry-trace data and only 3rd party baggage is present' , ( ) => {
@@ -849,6 +860,7 @@ describe('browserTracingIntegration', () => {
849860 public_key : 'examplePublicKey' ,
850861 sample_rate : '1' ,
851862 sampled : 'true' ,
863+ sample_rand : expect . any ( String ) ,
852864 trace_id : expect . not . stringContaining ( '12312012123120121231201212312012' ) ,
853865 } ) ;
854866
@@ -861,7 +873,7 @@ describe('browserTracingIntegration', () => {
861873 // make sampled false here, so we can see that it's being used rather than the tracesSampleRate-dictated one
862874 document . head . innerHTML =
863875 '<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-1">' +
864- '<meta name="baggage" content="sentry-release=2.1.14,foo=bar">' ;
876+ '<meta name="baggage" content="sentry-release=2.1.14,foo=bar,sentry-sample_rand=0.555 ">' ;
865877
866878 const client = new BrowserClient (
867879 getDefaultBrowserClientOptions ( {
@@ -881,7 +893,7 @@ describe('browserTracingIntegration', () => {
881893 } ,
882894 {
883895 sentryTrace : '12312012123120121231201212312011-1121201211212011-1' ,
884- baggage : 'sentry-release=2.2.14,foo=bar' ,
896+ baggage : 'sentry-release=2.2.14,foo=bar,sentry-sample_rand=0.123 ' ,
885897 } ,
886898 ) ;
887899
@@ -898,11 +910,12 @@ describe('browserTracingIntegration', () => {
898910 expect ( spanIsSampled ( idleSpan ) ) . toBe ( true ) ;
899911
900912 expect ( dynamicSamplingContext ) . toBeDefined ( ) ;
901- expect ( dynamicSamplingContext ) . toStrictEqual ( { release : '2.2.14' } ) ;
913+ expect ( dynamicSamplingContext ) . toStrictEqual ( { release : '2.2.14' , sample_rand : '0.123' } ) ;
902914
903915 // Propagation context keeps the custom trace data for later events on the same route to add them to the trace
904916 expect ( propagationContext . traceId ) . toEqual ( '12312012123120121231201212312011' ) ;
905917 expect ( propagationContext . parentSpanId ) . toEqual ( '1121201211212011' ) ;
918+ expect ( propagationContext . sampleRand ) . toEqual ( 0.123 ) ;
906919 } ) ;
907920 } ) ;
908921
0 commit comments