Skip to content

ref(tracing): Simplify sample_rate serialization for DSC #5475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/tracing/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ export class Transaction extends SpanClass implements TransactionInterface {
const { environment, release } = client.getOptions() || {};
const { publicKey: public_key } = client.getDsn() || {};

const rate = this.metadata && this.metadata.transactionSampling && this.metadata.transactionSampling.rate;
const sample_rate =
rate !== undefined
? rate.toLocaleString('fullwide', { useGrouping: false, maximumFractionDigits: 16 })
: undefined;
this.metadata &&
this.metadata.transactionSampling &&
this.metadata.transactionSampling.rate &&
this.metadata.transactionSampling.rate.toString();

const scope = hub.getScope();
const { segment: user_segment } = (scope && scope.getUser()) || {};
Expand Down
24 changes: 0 additions & 24 deletions packages/tracing/test/span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,30 +449,6 @@ describe('Span', () => {
expect(baggage && getThirdPartyBaggage(baggage)).toStrictEqual('');
});

test('exponential sample rate notation is converted to decimal notation', () => {
const transaction = new Transaction(
{
name: 'tx',
metadata: {
transactionSampling: { rate: 1.45e-14, method: 'client_rate' },
},
},
hub,
);

const baggage = transaction.getBaggage();

expect(baggage && isSentryBaggageEmpty(baggage)).toBe(false);
expect(baggage && getSentryBaggageItems(baggage)).toStrictEqual({
release: '1.0.1',
environment: 'production',
// transaction: 'tx',
sample_rate: '0.0000000000000145',
trace_id: expect.any(String),
});
expect(baggage && getThirdPartyBaggage(baggage)).toStrictEqual('');
});

describe('Including transaction name in DSC', () => {
test.each([
['is not included if transaction source is not set', undefined],
Expand Down