@@ -14,6 +14,13 @@ import { IdleTransaction } from './idletransaction';
1414import { Transaction } from './transaction' ;
1515import { hasTracingEnabled } from './utils' ;
1616
17+ const SAMPLING_METHODS = {
18+ explicit : 'explicitly_set' ,
19+ sampler : 'client_sampler' ,
20+ rate : 'client_rate' ,
21+ inheritance : 'inheritance' ,
22+ } ;
23+
1724/** Returns all trace headers that are currently on the top scope. */
1825function traceHeaders ( this : Hub ) : { [ key : string ] : string } {
1926 const scope = this . getScope ( ) ;
@@ -52,7 +59,7 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
5259
5360 // if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that
5461 if ( transaction . sampled !== undefined ) {
55- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : 'explicitly_set' } ;
62+ transaction . tags = { ...transaction . tags , __sentry_samplingMethod : SAMPLING_METHODS . explicit } ;
5663 return transaction ;
5764 }
5865
@@ -64,18 +71,18 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
6471 // cast the rate to a number first in case it's a boolean
6572 transaction . tags = {
6673 ...transaction . tags ,
67- __sentry_samplingMethod : 'client_sampler' ,
74+ __sentry_samplingMethod : SAMPLING_METHODS . sampler ,
6875 __sentry_sampleRate : String ( Number ( sampleRate ) ) ,
6976 } ;
7077 } else if ( samplingContext . parentSampled !== undefined ) {
7178 sampleRate = samplingContext . parentSampled ;
72- transaction . tags = { ...transaction . tags , __sentry_samplingMethod : ' inheritance' } ;
79+ transaction . tags = { ...transaction . tags , __sentry_samplingMethod : SAMPLING_METHODS . inheritance } ;
7380 } else {
7481 sampleRate = options . tracesSampleRate ;
7582 // cast the rate to a number first in case it's a boolean
7683 transaction . tags = {
7784 ...transaction . tags ,
78- __sentry_samplingMethod : 'client_rate' ,
85+ __sentry_samplingMethod : SAMPLING_METHODS . rate ,
7986 __sentry_sampleRate : String ( Number ( sampleRate ) ) ,
8087 } ;
8188 }
0 commit comments