@@ -45,7 +45,9 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
4545
4646 // if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that
4747 if ( transaction . sampled !== undefined ) {
48- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Explicit } ;
48+ transaction . setMetadata ( {
49+ transactionSampling : { method : TransactionSamplingMethod . Explicit } ,
50+ } ) ;
4951 return transaction ;
5052 }
5153
@@ -54,25 +56,27 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
5456 let sampleRate ;
5557 if ( typeof options . tracesSampler === 'function' ) {
5658 sampleRate = options . tracesSampler ( samplingContext ) ;
57- // cast the rate to a number first in case it's a boolean
58- transaction . tags = {
59- ... transaction . tags ,
60- __sentry_samplingMethod : TransactionSamplingMethod . Sampler ,
61- // TODO kmclb - once tag types are loosened, don't need to cast to string here
62- __sentry_sampleRate : String ( Number ( sampleRate ) ) ,
63- } ;
59+ transaction . setMetadata ( {
60+ transactionSampling : {
61+ method : TransactionSamplingMethod . Sampler ,
62+ // cast to number in case it's a boolean
63+ rate : Number ( sampleRate ) ,
64+ } ,
65+ } ) ;
6466 } else if ( samplingContext . parentSampled !== undefined ) {
6567 sampleRate = samplingContext . parentSampled ;
66- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Inheritance } ;
68+ transaction . setMetadata ( {
69+ transactionSampling : { method : TransactionSamplingMethod . Inheritance } ,
70+ } ) ;
6771 } else {
6872 sampleRate = options . tracesSampleRate ;
69- // cast the rate to a number first in case it's a boolean
70- transaction . tags = {
71- ... transaction . tags ,
72- __sentry_samplingMethod : TransactionSamplingMethod . Rate ,
73- // TODO kmclb - once tag types are loosened, don't need to cast to string here
74- __sentry_sampleRate : String ( Number ( sampleRate ) ) ,
75- } ;
73+ transaction . setMetadata ( {
74+ transactionSampling : {
75+ method : TransactionSamplingMethod . Rate ,
76+ // cast to number in case it's a boolean
77+ rate : Number ( sampleRate ) ,
78+ } ,
79+ } ) ;
7680 }
7781
7882 // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
0 commit comments