Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 6 additions & 1 deletion packages/core/src/tracing/sampling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export function sampleSpan(
const parsedSampleRate = parseSampleRate(sampleRate);

if (parsedSampleRate === undefined) {
DEBUG_BUILD && logger.warn('[Tracing] Discarding transaction because of invalid sample rate.');
DEBUG_BUILD &&
logger.warn(
`[Tracing] Discarding transaction because of invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
sampleRate,
)} of type ${JSON.stringify(typeof sampleRate)}.`,
);
return [false];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/hasTracingEnabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function hasTracingEnabled(
const options = maybeOptions || client?.getOptions();
return (
!!options &&
// Note: This check is `!= null`, meaning "nullish"
// Note: This check is `!= null`, meaning "nullish". `0` is not "nullish", `undefined` and `null` are. (This comment was brought to you by 15 minutes of questioning life)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol <3

(options.tracesSampleRate != null || !!options.tracesSampler)
);
}
9 changes: 0 additions & 9 deletions packages/core/src/utils/parseSampleRate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { DEBUG_BUILD } from '../debug-build';
import { logger } from '../utils-hoist/logger';

/**
* Parse a sample rate from a given value.
* This will either return a boolean or number sample rate, if the sample rate is valid (between 0 and 1).
Expand All @@ -15,12 +12,6 @@ export function parseSampleRate(sampleRate: unknown): number | undefined {

const rate = typeof sampleRate === 'string' ? parseFloat(sampleRate) : sampleRate;
if (typeof rate !== 'number' || isNaN(rate) || rate < 0 || rate > 1) {
DEBUG_BUILD &&
logger.warn(
`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
sampleRate,
)} of type ${JSON.stringify(typeof sampleRate)}.`,
);
return undefined;
}

Expand Down
Loading