Appearance
sentry
The sentry addon adds Sentry error tracking and performance monitoring. Works with both templates. Initialises the Sentry SDK on application startup and captures exceptions, performance traces, and error context automatically.
When to use it
Choose sentry when you want:
- Automatic error reporting with stack traces
- Performance monitoring for HTTP requests and database queries
- Release tracking and error aggregation
- Alerts for new or regressed issues
What it adds
Files
| File | Purpose |
|---|---|
src//integrations/__init__.py | Package marker (if not present) |
src//integrations/sentry.py | Sentry SDK initialisation with conditional enablement |
Sentry initialisation
The generated sentry.py:
- Reads
SENTRY_DSNfrom environment - no-ops when empty (safe for local dev) - For
fastapiprojects: includesFastApiIntegrationandSqlalchemyIntegration - For
blankprojects: basic Sentry SDK init
Settings fields
python
sentry_dsn: str = ""
sentry_environment: str = "development"Environment variables
| Key | Default | Description |
|---|---|---|
SENTRY_DSN | "" | Sentry project DSN (empty = disabled) |
SENTRY_ENVIRONMENT | development | Environment tag |
Dependencies
sentry-sdk[fastapi]- Sentry SDK with FastAPI integrationpython-dotenv-.envfile loading
Just recipes
| Recipe | Command |
|---|---|
just sentry-check | Print installed sentry-sdk version |
just sentry-test | Test Sentry initialisation and DSN configuration |
Startup wiring
- FastAPI: Injects
init_sentry()intolifespan_startupinlifecycle.py - Blank: Injects
init_sentry()intomain()before the return statement
Configuration
Getting a DSN
- Create a project at sentry.io
- Go to Settings → Projects → [your project] → Client Keys (DSN)
- Add to
.env:
bash
SENTRY_DSN=https://xxx@yyy.ingest.sentry.io/zzz
SENTRY_ENVIRONMENT=productionLeave SENTRY_DSN empty during local development. Sentry will be silently disabled.
Performance monitoring
The default configuration samples 100% of traces and profiles. Adjust in production by editing traces_sample_rate and profiles_sample_rate in sentry.py.
Post-installation
bash
just sentry-test # Verify Sentry is configured correctlyRemoving the addon
zenit remove sentry will:
- Delete
src//integrations/sentry.py - Remove
init_sentry()calls fromlifecycle.py(fastapi) ormain.py(blank) - Remove
sentry_dsnandsentry_environmentfrom settings - Remove
SENTRY_DSNandSENTRY_ENVIRONMENTfrom.envand.env.example - Remove
sentry-sdk[fastapi]frompyproject.toml - Remove sentry just recipes