Skip to content

Commit 3ee4735

Browse files
committed
stop stringifying all tags
1 parent 1424d26 commit 3ee4735

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

packages/core/test/lib/request.test.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('eventToSentryRequest', () => {
1818
environment,
1919
release,
2020
contexts: { trace: { trace_id: trace_id, span_id: '12261980', op: 'ball.fetch' } },
21-
// TODO
2221
user: { id: '1121', username: 'CharlieDog', ip_address: '11.21.20.12' },
2322
};
2423

@@ -40,7 +39,7 @@ describe('eventToSentryRequest', () => {
4039
tags: {
4140
dog: 'Charlie',
4241
__sentry_samplingMethod: TransactionSamplingMethod.Rate,
43-
__sentry_sampleRate: '.1121',
42+
__sentry_sampleRate: 0.1121,
4443
__sentry_tracestate: computeTracestate(tracestateObject),
4544
},
4645
transaction: '/dogs/are/great/',
@@ -90,15 +89,14 @@ describe('eventToSentryRequest', () => {
9089
});
9190

9291
[
93-
// TODO kmclb - once tag types are loosened, don't need to cast rate and undefined to strings here
94-
{ __sentry_samplingMethod: TransactionSamplingMethod.Rate, __sentry_sampleRate: '0.1121', dog: 'Charlie' },
95-
{ __sentry_samplingMethod: TransactionSamplingMethod.Sampler, __sentry_sampleRate: '0.1231', dog: 'Maisey' },
96-
{ __sentry_samplingMethod: TransactionSamplingMethod.Inheritance, __sentry_sampleRate: '', dog: 'Cory' },
97-
{ __sentry_samplingMethod: TransactionSamplingMethod.Explicit, __sentry_sampleRate: '', dog: 'Bodhi' },
92+
{ __sentry_samplingMethod: TransactionSamplingMethod.Rate, __sentry_sampleRate: 0.1121, dog: 'Charlie' },
93+
{ __sentry_samplingMethod: TransactionSamplingMethod.Sampler, __sentry_sampleRate: 0.1231, dog: 'Maisey' },
94+
{ __sentry_samplingMethod: TransactionSamplingMethod.Inheritance, dog: 'Cory' },
95+
{ __sentry_samplingMethod: TransactionSamplingMethod.Explicit, dog: 'Bodhi' },
9896

9997
// this shouldn't ever happen (tags should always include at least the sampling method), but good to know that
10098
// things won't blow up if it does happen
101-
{ __sentry_samplingMethod: '', __sentry_sampleRate: '', dog: 'Lucy' },
99+
{ dog: 'Lucy' },
102100
].forEach(tags => {
103101
const { __sentry_samplingMethod: method, __sentry_sampleRate: rate, dog } = tags;
104102

@@ -115,8 +113,7 @@ describe('eventToSentryRequest', () => {
115113

116114
expect(itemHeader).toEqual({
117115
type: 'transaction',
118-
// TODO kmclb - once tag types are loosened, don't need to cast to string here
119-
sample_rates: [{ id: String(method), rate: String(rate) }],
116+
sample_rates: [{ id: method, rate }],
120117
});
121118
});
122119
});

packages/tracing/src/hubextensions.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
6565
transaction.tags = {
6666
...transaction.tags,
6767
__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)),
68+
__sentry_sampleRate: Number(sampleRate),
7069
};
7170
} else if (samplingContext.parentSampled !== undefined) {
7271
sampleRate = samplingContext.parentSampled;
@@ -77,8 +76,7 @@ function sample<T extends Transaction>(hub: Hub, transaction: T, samplingContext
7776
transaction.tags = {
7877
...transaction.tags,
7978
__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)),
79+
__sentry_sampleRate: Number(sampleRate),
8280
};
8381
}
8482

packages/tracing/test/hub.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ describe('Hub', () => {
325325
const transaction = hub.startTransaction({ name: 'dogpark' });
326326

327327
expect(transaction.tags).toEqual(
328-
expect.objectContaining({ __sentry_samplingMethod: 'client_sampler', __sentry_sampleRate: '0.1121' }),
328+
expect.objectContaining({ __sentry_samplingMethod: 'client_sampler', __sentry_sampleRate: 0.1121 }),
329329
);
330330
});
331331

@@ -341,7 +341,7 @@ describe('Hub', () => {
341341
const transaction = hub.startTransaction({ name: 'dogpark' });
342342

343343
expect(transaction.tags).toEqual(
344-
expect.objectContaining({ __sentry_samplingMethod: 'client_rate', __sentry_sampleRate: '0.1121' }),
344+
expect.objectContaining({ __sentry_samplingMethod: 'client_rate', __sentry_sampleRate: 0.1121 }),
345345
);
346346
});
347347
});

0 commit comments

Comments
 (0)