ref(options): add Python sentry-options client (infra)#8113
Open
phacops wants to merge 2 commits into
Open
Conversation
Introduce the Python binding of the sentry-options client that Snuba's Rust
consumers already use (via the sentry-options crate), so Python code can read
the same read-only 'snuba' namespace. No runtime-config call sites are migrated
in this PR; it is the shared foundation for the per-module migration PRs that
follow.
- Dependency: sentry-options>=1.1.1 (pyproject.toml, uv.lock).
- snuba/state/sentry_options.py:
- init_options(): idempotent, never raises (a missing/misconfigured options
mount must not break startup); called from setup_sentry(), the chokepoint
every entrypoint and pytest_configure already hits.
- get_option(key, default) + typed get_bool/int/float/str_option, and the
get_mapped_* family for dict-valued (additionalProperties) options keyed by
a dynamic name. All fall back to the caller default on any OptionsError,
mirroring the Rust .ok()...unwrap_or(default) semantics so call sites behave
exactly as before once they migrate.
- tests/conftest.py points SENTRY_OPTIONS_DIR at the in-repo schema so init()
reads the committed schema regardless of how tests are launched.
- The schema declares the keys exercised by test_sentry_options.py; the
remaining keys land alongside their call-site migrations in the follow-up PRs.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01U2Cu68uGZRcCVS14jcyd3E
This was referenced Jun 26, 2026
onewland
approved these changes
Jun 29, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Splits the runtime-config → sentry-options migration (#8096, 112 files) into reviewable, module-scoped PRs per review feedback. This is the base of the stack: the shared Python client, with no call sites migrated. The per-module migration PRs stack on top of this one.
It introduces the Python binding of the same sentry-options client Snuba's Rust consumers already use (via the
sentry-optionscrate, e.g.blq_router.rs), so Python code can read the same read-onlysnubanamespace.Contents
sentry-options>=1.1.1(pyproject.toml,uv.lock) — the Python binding of the client the Rust consumers use.snuba/state/sentry_options.py:init_options()— idempotent, never raises (a missing/misconfigured options mount must not break startup); called fromsetup_sentry(), the chokepoint every entrypoint andpytest_configurealready hits.get_option(key, default)and typedget_bool_option/get_int_option/get_float_option/get_str_option, plus theget_mapped_*family for dict-valued (additionalProperties) options keyed by a dynamic name. All fall back to the callerdefaulton anyOptionsError, mirroring the Rust.ok()…unwrap_or(default)semantics so call sites behave exactly as before once migrated.tests/conftest.pypointsSENTRY_OPTIONS_DIRat the in-repo schema soinit()reads the committed schema regardless of how tests are launched.test_sentry_options.py; the remaining ~90 keys land alongside their call-site migrations in the stacked follow-up PRs.Stack
This PR is the base. Domain PRs stack on it (EAP/RPC query path, storage routing + ConfigurableComponent, rate limiting, replacer, deletes, query-exec/ClickHouse, subscriptions/consumers). The Rust consumer slice is independent (#8112) since it needs no Python infra.
Verification
pytest tests/state/test_sentry_options.py→ 13 passed;ruff check+ruff format --checkclean;mypyclean on changed source.🤖 Generated with Claude Code
Generated by Claude Code