feat(options): Add runtime options for killswitches#421
Draft
feat(options): Add runtime options for killswitches#421
Conversation
…ry-options support Introduces the `objectstore-options` crate, which wraps `sentry-options` and exposes Objectstore-specific runtime configuration. Includes: - `Options` struct with a global `OnceLock<RwLock<Options>>` snapshot refreshed every 5s - `init()` function that loads an initial snapshot and spawns a background refresh task - `Killswitch` type (plain data, deserialized from options) with usecase, scopes, and service fields - Test-mode `Options::get()` that deserializes fresh from a thread-local instance, enabling `sentry_options::testing::override_options` to work without calling `init()` - Objectstore killswitches JSON schema added to `sentry-options/schemas/objectstore/` - `objectstore_options::init(None)` wired into the server CLI startup path
- Wire objectstore-options into objectstore-server killswitches, replacing the static config-backed implementation with live-reloading via sentry-options - Switch objectstore-options global to OnceLock<ArcSwap<Options>> for lock-free reads - Patch sentry-options to feat/additional-properties-map-schema branch to support object-typed schema fields with additionalProperties
…stale comment Only spawn the background refresh task when OPTIONS.set() succeeds, so concurrent callers cannot produce multiple refresh tasks and filesystem watchers. Also remove a low-value inline comment in killswitches.rs.
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.
sentry-optionsdelivers runtime configuration as untyped JSON blobs. Using it directly means matching option names at every callsite, cloning values out of the snapshot, and accepting that deserialization can fail at any moment.objectstore-optionswrapssentry-optionswith a typed, infallible interface:Optionsstruct; callers borrow fields directly without knowing option names or schema layout.Options::get()always returns the last successfully loaded snapshot. A refresh failure logs a warning but keeps the previous values; the call site can never observe an error.Arc<Options>snapshot, so read-heavy paths pay no allocation cost.Result;init()fails loudly at startup if the initial snapshot can't be deserialized, and no.unwrap()is hidden in production paths.In test builds the
testingfeature replacesOptions::get()with a path that reads directly from schema defaults and the thread-local override mechanism fromsentry-options, so unit tests work without callinginit().The second commit wires killswitches into this: the static YAML-configured switches and the live options switches are merged at match time, so both sources work during the rollout period.
Two follow-ups are planned but out of scope here:
schema.jsonfrom Rust types at compile time instead of maintaining it by hand.