Skip to main content
Get sentry-options working in your project with this step-by-step guide.

Installation

Install the client library for your language:
[dependencies]
sentry-options = "0.0.14"

Create a schema

Define your configuration options in a JSON schema file. Create sentry-options/schemas/{namespace}/schema.json:
{
  "version": "1.0",
  "type": "object",
  "properties": {
    "feature.enabled": {
      "type": "boolean",
      "default": false,
      "description": "Enable the feature"
    },
    "feature.rate_limit": {
      "type": "integer",
      "default": 100,
      "description": "Rate limit per second"
    }
  }
}
The namespace directory must match your repository name or be prefixed with it (e.g., seer, seer-autofix).

Supported types

TypeJSON SchemaExample Default
String"type": "string""default": "value"
Integer"type": "integer""default": 42
Float"type": "number""default": 3.14
Boolean"type": "boolean""default": false
Array"type": "array""default": [1, 2, 3]
Array types require an items field: "items": {"type": "string"}. Nested arrays are not yet supported.

Use in your code

1

Initialize the library

Do this once during application startup:
from sentry_options import init

# Initialize early in your startup sequence
init()
The library automatically loads schemas and values from:
  1. SENTRY_OPTIONS_DIR environment variable, or
  2. /etc/sentry-options if it exists, or
  3. sentry-options/ in your working directory
2

Get an options namespace

from sentry_options import options

# Get options for your namespace
opts = options('my-service')
3

Read option values

# Read values (returns schema default if not set)
if opts.get('feature.enabled'):
    rate = opts.get('feature.rate_limit')
    print(f"Feature enabled with rate limit: {rate}")
Values are validated against your schema. If no value is configured, the schema default is returned.

Complete example

Here’s a working example that reads options every 3 seconds:
from sentry_options import init, options
import time

# Initialize the library
init()

# Get options namespace
testing = options('sentry-options-testing')

# Read values periodically
while True:
    time.sleep(3)
    example_val = testing.get('example-option')
    float_val = testing.get('float-option')
    bool_val = testing.get('bool-option')
    string_val = testing.get('string-option')
    print(
        f"values: {example_val} | {float_val} | {bool_val} | {string_val}",
        flush=True,
    )

Test locally

Create a values file to override schema defaults for local development:
# Create values directory
mkdir -p sentry-options/values/my-service

# Create values file
cat > sentry-options/values/my-service/values.json << 'EOF'
{
  "options": {
    "feature.enabled": true,
    "feature.rate_limit": 200
  }
}
EOF
The directory structure should look like:
sentry-options/
├── schemas/
│   └── my-service/
│       └── schema.json
└── values/
    └── my-service/
        └── values.json
Run your application and it will automatically pick up the values. Update values.json while the app is running to test hot-reload (changes detected within ~5 seconds).
For local testing, the library looks for sentry-options/ in your current working directory by default.

Next steps

Integration guide

Complete guide to integrating sentry-options in production

API reference

Full API documentation for Python and Rust clients

Schema definition

Learn about schema format and validation rules

Hot-reload

Understand how configuration updates work

Build docs developers (and LLMs) love