feat(options): read sample rates from env vars by jpnurmi · Pull Request #1540 · getsentry/sentry-native
bot reviewed Feb 23, 2026
Reject NaN values parsed from SENTRY_SAMPLE_RATE and SENTRY_TRACES_SAMPLE_RATE, as NaN bypasses the clamping logic in the setter functions. Also restore env vars after tests and add a NaN-specific test case. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract parse_double_env helper to deduplicate sample rate env parsing and tolerate trailing whitespace. Replace SETENV/UNSETENV macros with pushenv/popenv functions that clone the old value before overwriting, preventing use of dangling getenv pointers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace isnan with !isfinite to also reject inf/-inf values, which would otherwise get clamped and silently enable full sampling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move env var double parsing from sentry_options.c into a reusable sentry__getenv_double(name, fallback) helper in sentry_utils. This simplifies option initialization to inline calls and moves parsing tests to test_utils.c where they test the utility directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jpnurmi
deleted the
jpnurmi/feat/env-vars
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters