getsentry/agent-skills/sentry-python-sdk
Claude Code and agent skill by getsentry/agent-skills
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Full Sentry SDK setup for Python. Use when asked to "add Sentry to Python", "install sentry-sdk", "setup Sentry in Python", or configure error monitoring, tracing, profiling, logging, metrics, crons, or AI monitoring for Python applications. Supports Django, Flask, FastAPI, Celery, Starlette, AIOHTTP, Tornado, and more.
Install
npx vskill@latest install getsentry/agent-skills/sentry-python-sdkSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Sentry Python SDK
Opinionated wizard that scans your Python project and guides you through complete Sentry setup.
Invoke This Skill When
- User asks to "add Sentry to Python" or "setup Sentry" in a Python app
- User wants error monitoring, tracing, profiling, logging, metrics, or crons in Python
- User mentions
sentry-sdk,sentry_sdk, or Sentry + any Python framework - User wants to monitor Django views, Flask routes, FastAPI endpoints, Celery tasks, or scheduled jobs
Note: SDK versions and APIs below reflect Sentry docs at time of writing (sentry-sdk 2.x).Always verify against docs.sentry.io/platforms/python/ before implementing.
Phase 1: Detect
Run these commands to understand the project before making recommendations:
What to note:
- Is
sentry-sdkalready in requirements? If yes, check ifsentry_sdk.init()is present — may just need feature config. - Which framework? (Determines where to place
sentry_sdk.init().) - Which task queue? (Celery needs dual-process init; RQ needs a settings file.)
- AI libraries? (OpenAI, Anthropic, LangChain are auto-instrumented.)
- Companion frontend? (Triggers Phase 4 cross-link.)
Phase 2: Recommend
Based on what you found, present a concrete proposal. Don't ask open-ended questions — lead with a recommendation:
Always recommended (core coverage):
- ✅ Error Monitoring — captures unhandled exceptions, supports
ExceptionGroup(Python 3.11+) - ✅ Logging — Python
loggingstdlib auto-captured; enhanced if Loguru detected
Recommend when detected:
- ✅ Tracing — HTTP framework detected (Django/Flask/FastAPI/etc.)
- ✅ AI Monitoring — OpenAI/Anthropic/LangChain/etc. detected (auto-instrumented, zero config)
- ⚡ Profiling — production apps where performance matters
- ⚡ Crons — Celery Beat, APScheduler, or cron patterns detected
- ⚡ Metrics — business KPIs, SLO tracking
Recommendation matrix:
| Feature | Recommend when... | Reference | |
|---|---|---|---|
| Error Monitoring | Always — non-negotiable baseline | ${SKILL_ROOT}/references/error-monitoring.md | |
| Tracing | Django/Flask/FastAPI/AIOHTTP/etc. detected | ${SKILL_ROOT}/references/tracing.md | |
| Profiling | Production + performance-sensitive workload | ${SKILL_ROOT}/references/profiling.md | |
| Logging | Always (stdlib); enhanced for Loguru | ${SKILL_ROOT}/references/logging.md | |
| Metrics | Business events or SLO tracking needed | ${SKILL_ROOT}/references/metrics.md | |
| Crons | Celery Beat, APScheduler, or cron patterns | ${SKILL_ROOT}/references/crons.md | |
| AI Monitoring | OpenAI/Anthropic/LangChain/etc. detected | ${SKILL_ROOT}/references/ai-monitoring.md |
Propose: "I recommend Error Monitoring + Tracing [+ Logging if applicable]. Want Profiling, Crons, or AI Monitoring too?"
Phase 3: Guide
Install
Extras are optional — plainsentry-sdkworks for all frameworks. Extras install complementary packages.
Quick Start — Recommended Init
Full init enabling the most features with sensible defaults. Place before any app/framework code:
Where to Initialize Per Framework
| Framework | Where to call sentry_sdk.init() | Notes | |
|---|---|---|---|
| Django | Top of settings.py, before any imports | No middleware needed — Sentry patches Django internally | |
| Flask | Before app = Flask(__name__) | Must precede app creation | |
| FastAPI | Before app = FastAPI() | StarletteIntegration + FastApiIntegration auto-enabled together | |
| Starlette | Before app = Starlette(...) | Same auto-integration as FastAPI | |
| AIOHTTP | Module level, before web.Application() | ||
| Tornado | Module level, before app setup | No integration class needed | |
| Quart | Before app = Quart(__name__) | ||
| Falcon | Module level, before app = falcon.App() | ||
| Sanic | Inside @app.listener("before_server_start") | Sanic's lifecycle requires async init | |
| Celery | @signals.celeryd_init.connect in worker AND in calling process | Dual-process init required | |
| RQ | mysettings.py loaded by worker via rq worker -c mysettings | ||
| ARQ | Both worker module and enqueuing process |
Django example (settings.py):
FastAPI example (main.py):
Auto-Enabled vs Explicit Integrations
Most integrations activate automatically when their package is installed — no integrations=[...] needed:
| Auto-enabled | Explicit required | |
|---|---|---|
| Django, Flask, FastAPI, Starlette, AIOHTTP, Tornado, Quart, Falcon, Sanic, Bottle | DramatiqIntegration | |
| Celery, RQ, Huey, ARQ | GRPCIntegration | |
| SQLAlchemy, Redis, asyncpg, pymongo | StrawberryIntegration | |
| Requests, HTTPX, aiohttp-client | AsyncioIntegration | |
| OpenAI, Anthropic, LangChain, Pydantic AI, MCP | OpenTelemetryIntegration | |
Python logging, Loguru | WSGIIntegration / ASGIIntegration |
For Each Agreed Feature
Walk through features one at a time. Load the reference, follow its steps, verify before moving on:
| Feature | Reference file | Load when... | |
|---|---|---|---|
| Error Monitoring | ${SKILL_ROOT}/references/error-monitoring.md | Always (baseline) | |
| Tracing | ${SKILL_ROOT}/references/tracing.md | HTTP handlers / distributed tracing | |
| Profiling | ${SKILL_ROOT}/references/profiling.md | Performance-sensitive production | |
| Logging | ${SKILL_ROOT}/references/logging.md | Always; enhanced for Loguru | |
| Metrics | ${SKILL_ROOT}/references/metrics.md | Business KPIs / SLO tracking | |
| Crons | ${SKILL_ROOT}/references/crons.md | Scheduler / cron patterns detected | |
| AI Monitoring | ${SKILL_ROOT}/references/ai-monitoring.md | AI library detected |
For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.
Configuration Reference
Key sentry_sdk.init() Options
| Option | Type | Default | Purpose | |
|---|---|---|---|---|
dsn | str | None | SDK disabled if empty; env: SENTRY_DSN | |
environment | str | "production" | e.g., "staging"; env: SENTRY_ENVIRONMENT | |
release | str | None | e.g., "myapp@1.0.0"; env: SENTRY_RELEASE | |
send_default_pii | bool | False | Include IP, headers, cookies, auth user | |
traces_sample_rate | float | None | Transaction sample rate; None disables tracing | |
traces_sampler | Callable | None | Custom per-transaction sampling (overrides rate) | |
profile_session_sample_rate | float | None | Continuous profiling session rate | |
profile_lifecycle | str | "manual" | "trace" = auto-start profiler with spans | |
profiles_sample_rate | float | None | Transaction-based profiling rate | |
enable_logs | bool | False | Send logs to Sentry (SDK ≥ 2.35.0) | |
sample_rate | float | 1.0 | Error event sample rate | |
attach_stacktrace | bool | False | Stack traces on capture_message() | |
max_breadcrumbs | int | 100 | Max breadcrumbs per event | |
debug | bool | False | Verbose SDK debug output | |
before_send | Callable | None | Hook to mutate/drop error events | |
before_send_transaction | Callable | None | Hook to mutate/drop transaction events | |
ignore_errors | list | [] | Exception types or regex patterns to suppress | |
auto_enabling_integrations | bool | True | Set False to disable all auto-detection |
Environment Variables
| Variable | Maps to | Notes | |
|---|---|---|---|
SENTRY_DSN | dsn | ||
SENTRY_RELEASE | release | Also auto-detected from git SHA, Heroku, CircleCI, CodeBuild, GAE | |
SENTRY_ENVIRONMENT | environment | ||
SENTRY_DEBUG | debug |
Verification
Test that Sentry is receiving events:
Or for a non-crashing check:
If nothing appears:
- Set
debug=Trueinsentry_sdk.init()— prints SDK internals to stdout - Verify the DSN is correct
- Check
SENTRY_DSNenv var is set in the running process - For Celery/RQ: ensure init runs in the worker process, not just the calling process
Phase 4: Cross-Link
After completing Python setup, check for a companion frontend missing Sentry:
If a frontend exists without Sentry, suggest the matching skill:
| Frontend detected | Suggest skill | |
|---|---|---|
| React / Next.js | sentry-react-sdk | |
| Svelte / SvelteKit | sentry-svelte-sdk | |
| Vue / Nuxt | Use @sentry/vue — see docs.sentry.io/platforms/javascript/guides/vue/ | |
| Other JS/TS | sentry-react-sdk (covers generic browser JS patterns) |
Troubleshooting
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sentry-python-sdk/SKILL.md
Popularity
- Repository stars
- 18
- Repository forks
- 2
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 Mar 2026, 8 months ago.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/getsentry/agent-skills/sentry-python-sdk)