Skip to content

Commit f6c9581

Browse files
authored
Exclude 1.0 from allows values for sample_rand (#12197)
For the invariant mentioned on the page to hold true, the `sample_rand` cannot be `1.0` but instead has to be less.
1 parent fb6c22e commit f6c9581

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

develop-docs/sdk/telemetry/traces/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ If no `tracesSampler` callback is used, the SDK fully inherits sampling decision
232232

233233
The random value is set according to the following rules:
234234

235-
1. When an SDK starts a new trace, `sample_rand` is always set to a random number in the range of `[0, 1]`. This explicitly includes traces that aren't sampled, as well as when the `tracesSampleRate` is set to `0.0` or `1.0`.
235+
1. When an SDK starts a new trace, `sample_rand` is always set to a random number in the range of `[0, 1)` (including 0.0, excluding 1.0). This explicitly includes traces that aren't sampled, as well as when the `tracesSampleRate` is set to `0.0` or `1.0`.
236236
2. It is _recommended_ to generate the random number deterministically using the trace ID as seed or source of randomness. The exact method by which the random number is created is implementation defined and may vary between SDK implementations. See 4. on why this behaviour is desirable.
237237
3. On incoming traces, an SDK assumes the `sample_rand` value along with the rest of the DSC, overriding an existing value if needed.
238238
4. If `sample_rand` is missing on an incoming trace, the SDK creates and from now on propagates a new random number on-the-fly, based on the following rules:
239239
1. If `sample_rate` and `sampled` are propgated, create `sample_rand` so that it adheres to the invariant. This means, for a decision of `True` generate a random number in half-open range `[0, rate)` and for a decision of `False` generate a random number in range `[rate, 1]`.
240-
2. If the sampling decision is missing, generate a random number in range of `[0, 1]`, like for a new trace.
240+
2. If the sampling decision is missing, generate a random number in range of `[0, 1)` (including 0.0, excluding 1.0), like for a new trace.
241241

242242
The SDK should always use the stored random number (`sentry-sample_rand`) for sampling decisions and should no longer rely on `math.random()` or similar functions in tracing code:
243243

0 commit comments

Comments
 (0)