Skip to content

Commit 978be42

Browse files
committed
store sampling data in metadata property rather than tags
1 parent cf311f1 commit 978be42

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

packages/tracing/src/hubextensions.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
5252

5353
// if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that
5454
if (transaction.sampled !== undefined) {
55-
transaction.tags = { ...transaction.tags, __sentry_samplingMethod: TransactionSamplingMethod.Explicit };
55+
transaction.setMetadata({
56+
transactionSampling: { method: TransactionSamplingMethod.Explicit },
57+
});
5658
return transaction;
5759
}
5860

@@ -61,25 +63,27 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
6163
let sampleRate;
6264
if (typeof options.tracesSampler === 'function') {
6365
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+
});
7173
} else if (samplingContext.parentSampled !== undefined) {
7274
sampleRate = samplingContext.parentSampled;
73-
transaction.tags = { ...transaction.tags, __sentry_samplingMethod: TransactionSamplingMethod.Inheritance };
75+
transaction.setMetadata({
76+
transactionSampling: { method: TransactionSamplingMethod.Inheritance },
77+
});
7478
} else {
7579
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+
});
8387
}
8488

8589
// 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

Comments
 (0)