Skip to content

ref(options): add Python sentry-options client (infra)#8113

Open
phacops wants to merge 2 commits into
masterfrom
claude/options-migration-infra
Open

ref(options): add Python sentry-options client (infra)#8113
phacops wants to merge 2 commits into
masterfrom
claude/options-migration-infra

Conversation

@phacops

@phacops phacops commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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-options crate, e.g. blq_router.rs), so Python code can read the same read-only snuba namespace.

Contents

  • Dependency: 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 from setup_sentry(), the chokepoint every entrypoint and pytest_configure already hits.
    • get_option(key, default) and typed get_bool_option / get_int_option / get_float_option / get_str_option, plus 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 migrated.
  • 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 only the keys exercised by 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 --check clean; mypy clean on changed source.

🤖 Generated with Claude Code


Generated by Claude Code

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants