Initialize the library once during application startup:
Python
Rust
from sentry_options import init# Call once early in your application startupinit()
The init() function:
Loads all schemas from /etc/sentry-options/schemas/ (or SENTRY_OPTIONS_DIR)
Loads values from /etc/sentry-options/values/
Validates values against schemas
Starts background file watcher for hot-reload
use sentry_options::init;fn main() -> anyhow::Result<()> { // Call once early in your application startup init()?; // Your application code Ok(())}
The init() function:
Loads all schemas from /etc/sentry-options/schemas/ (or SENTRY_OPTIONS_DIR)
Loads values from /etc/sentry-options/values/
Validates values against schemas
Starts background file watcher for hot-reload
Call init() only once during application startup. Calling it multiple times will raise an InitializationError (Python) or AlreadyInitialized error (Rust).
use std::{thread::sleep, time::Duration};use sentry_options::{init, options};/// An example usage of the Rust options client library/// Every 3 seconds, prints out the value of example-option, float-option, and bool-option////// Updating values in `../values` will be reflected in stdout/// ^C to exitfn main() -> anyhow::Result<()> { init()?; let sentry_options = options("sentry-options-testing"); loop { sleep(Duration::from_secs(3)); let string_value = sentry_options.get("example-option")?; let float_value = sentry_options.get("float-option")?; let bool_value = sentry_options.get("bool-option")?; println!( "values: {} | {} | {}", string_value, float_value, bool_value ); }}
Determine whether an option has an explicit value or is using the schema default:
Python
Rust
from sentry_options import optionsopts = options('seer')# Check if value is explicitly setif opts.isset('feature.enabled'): print("Feature enabled is explicitly configured")else: print("Feature enabled is using schema default")
Returns:
True if the option has an explicit value in the values file
False if using the schema default
Raises UnknownOptionError if option doesn’t exist in schema
use sentry_options::options;let opts = options("seer");// Check if value is explicitly setif opts.isset("feature.enabled")? { println!("Feature enabled is explicitly configured");} else { println!("Feature enabled is using schema default");}
Returns:
Ok(true) if the option has an explicit value in the values file
Ok(false) if using the schema default
Err(OptionsError::UnknownOption) if option doesn’t exist in schema