1
1
import { getActiveDomain , getMainCarrier , Hub } from '@sentry/hub' ;
2
- import { CustomSamplingContext , SamplingContext , TransactionContext } from '@sentry/types' ;
2
+ import { CustomSamplingContext , SamplingContext , TransactionContext , TransactionSamplingMethod } from '@sentry/types' ;
3
3
import {
4
4
dynamicRequire ,
5
5
extractNodeRequestData ,
@@ -52,7 +52,7 @@ 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 : 'explicitly_set' } ;
55
+ transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Explicit } ;
56
56
return transaction ;
57
57
}
58
58
@@ -64,18 +64,20 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
64
64
// cast the rate to a number first in case it's a boolean
65
65
transaction . tags = {
66
66
...transaction . tags ,
67
- __sentry_samplingMethod : 'client_sampler' ,
67
+ __sentry_samplingMethod : TransactionSamplingMethod . Sampler ,
68
+ // TODO kmclb - once tag types are loosened, don't need to cast to string here
68
69
__sentry_sampleRate : String ( Number ( sampleRate ) ) ,
69
70
} ;
70
71
} else if ( samplingContext . parentSampled !== undefined ) {
71
72
sampleRate = samplingContext . parentSampled ;
72
- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : 'inheritance' } ;
73
+ transaction . tags = { ...transaction . tags , __sentry_samplingMethod : TransactionSamplingMethod . Inheritance } ;
73
74
} else {
74
75
sampleRate = options . tracesSampleRate ;
75
76
// cast the rate to a number first in case it's a boolean
76
77
transaction . tags = {
77
78
...transaction . tags ,
78
- __sentry_samplingMethod : 'client_rate' ,
79
+ __sentry_samplingMethod : TransactionSamplingMethod . Rate ,
80
+ // TODO kmclb - once tag types are loosened, don't need to cast to string here
79
81
__sentry_sampleRate : String ( Number ( sampleRate ) ) ,
80
82
} ;
81
83
}
0 commit comments