@@ -45,7 +45,9 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
45
45
46
46
// if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that
47
47
if ( transaction . sampled !== undefined ) {
48
- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Explicit } ;
48
+ transaction . setMetadata ( {
49
+ transactionSampling : { method : TransactionSamplingMethod . Explicit } ,
50
+ } ) ;
49
51
return transaction ;
50
52
}
51
53
@@ -54,25 +56,27 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
54
56
let sampleRate ;
55
57
if ( typeof options . tracesSampler === 'function' ) {
56
58
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
+ } ) ;
64
66
} else if ( samplingContext . parentSampled !== undefined ) {
65
67
sampleRate = samplingContext . parentSampled ;
66
- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Inheritance } ;
68
+ transaction . setMetadata ( {
69
+ transactionSampling : { method : TransactionSamplingMethod . Inheritance } ,
70
+ } ) ;
67
71
} else {
68
72
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
+ } ) ;
76
80
}
77
81
78
82
// 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