@@ -52,7 +52,9 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
52
52
53
53
// if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that
54
54
if ( transaction . sampled !== undefined ) {
55
- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Explicit } ;
55
+ transaction . setMetadata ( {
56
+ transactionSampling : { method : TransactionSamplingMethod . Explicit } ,
57
+ } ) ;
56
58
return transaction ;
57
59
}
58
60
@@ -61,25 +63,27 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
61
63
let sampleRate ;
62
64
if ( typeof options . tracesSampler === 'function' ) {
63
65
sampleRate = options . tracesSampler ( samplingContext ) ;
64
- // cast the rate to a number first in case it's a boolean
65
- transaction . tags = {
66
- ... transaction . tags ,
67
- __sentry_samplingMethod : TransactionSamplingMethod . Sampler ,
68
- // TODO kmclb - once tag types are loosened, don't need to cast to string here
69
- __sentry_sampleRate : String ( Number ( sampleRate ) ) ,
70
- } ;
66
+ transaction . setMetadata ( {
67
+ transactionSampling : {
68
+ method : TransactionSamplingMethod . Sampler ,
69
+ // cast to number in case it's a boolean
70
+ rate : Number ( sampleRate ) ,
71
+ } ,
72
+ } ) ;
71
73
} else if ( samplingContext . parentSampled !== undefined ) {
72
74
sampleRate = samplingContext . parentSampled ;
73
- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Inheritance } ;
75
+ transaction . setMetadata ( {
76
+ transactionSampling : { method : TransactionSamplingMethod . Inheritance } ,
77
+ } ) ;
74
78
} else {
75
79
sampleRate = options . tracesSampleRate ;
76
- // cast the rate to a number first in case it's a boolean
77
- transaction . tags = {
78
- ... transaction . tags ,
79
- __sentry_samplingMethod : TransactionSamplingMethod . Rate ,
80
- // TODO kmclb - once tag types are loosened, don't need to cast to string here
81
- __sentry_sampleRate : String ( Number ( sampleRate ) ) ,
82
- } ;
80
+ transaction . setMetadata ( {
81
+ transactionSampling : {
82
+ method : TransactionSamplingMethod . Rate ,
83
+ // cast to number in case it's a boolean
84
+ rate : Number ( sampleRate ) ,
85
+ } ,
86
+ } ) ;
83
87
}
84
88
85
89
// 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