sentry-python-setup

Setup Sentry in Python apps. Use when asked to add Sentry to Python, install sentry-sdk, or configure error monitoring, profiling, or logging for Python applications, Django, Flask, FastAPI.

getsentry/agent-skills20 installsApache-2.0Synced Aug 25

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: sentry-python-setup
description: Setup Sentry in Python apps. Use when asked to add Sentry to Python, install sentry-sdk, or configure error monitoring, profiling, or logging for Python applications, Django, Flask, FastAPI.
license: Apache-2.0
---

# Sentry Python Setup

Install and configure Sentry in Python projects.

## Invoke This Skill When

- User asks to "add Sentry to Python" or "install Sentry" in a Python app
- User wants error monitoring, logging, or tracing in Python
- User mentions "sentry-sdk" or Python frameworks (Django, Flask, FastAPI)

**Important:** The configuration options and code samples below are examples. Always verify against [docs.sentry.io](https://docs.sentry.io) before implementing, as APIs and defaults may have changed.

## Install

```bash
pip install sentry-sdk
```

## Configure

Initialize as early as possible in your application:

```python
import sentry_sdk

sentry_sdk.init(
    dsn="YOUR_SENTRY_DSN",
    send_default_pii=True,
    
    # Tracing
    traces_sample_rate=1.0,
    
    # Profiling
    profile_session_sample_rate=1.0,
    profile_lifecycle="trace",
    
    # Logs
    enable_logs=True,
)
```

### Async Applications

For async apps, initialize inside an async function:

```python
import asyncio
import sentry_sdk

async def main():
    sentry_sdk.init(
        dsn="YOUR_SENTRY_DSN",
        send_default_pii=True,
        traces_sample_rate=1.0,
        enable_logs=True,
    )
    # ... rest of app

asyncio.run(main())
```

## Framework Integrations

Use the same `sentry_sdk.init()` call shown above. Place it where it runs before your app starts:

| Framework | Where to Init | Notes |
|-----------|--------------|-------|
| **Django** | Top of `settings.py` | Auto-detects Django, no extra install |
| **Flask** | Before `app = Flask(__name__)` | Auto-detects Flask |
| **FastAPI** | Before `app = FastAPI()` | Auto-detects FastAPI |
| **Celery** | In Celery worker config | Auto-detects Celery |
| **AIOHTTP** | Before app creation | Auto-detects AIOHTTP |

## Configuration Options

| Option | Description | Default | Min SDK |
|--------|-------------|---------|---------|
| `dsn` | Sentry DSN | `None` (SDK no-ops without it) | — |
| `send_default_pii` | Include user data | `None` | — |
| `traces_sample_rate` | % of transactions traced | `None` (tracing disabled) | — |
| `profile_session_sample_rate` | % of sessions profiled | `None` (profiling disabled) | 2.24.1+ |
| `profile_lifecycle` | Profiling mode (`"trace"` or `"manual"`) | `"manual"` | 2.24.1+ |
| `enable_logs` | Send logs to Sentry | `False` | 2.35.0+ |
| `environment` | Environment name | `"production"` (or `SENTRY_ENVIRONMENT` env var) | — |
| `release` | Release version | Auto-detected | — |

## Environment Variables

The SDK auto-reads these:

```bash
SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_ENVIRONMENT=production
SENTRY_RELEASE=1.0.0
```

For `sentry-cli` (source maps, releases), also set:

```bash
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project
```

Or pass DSN in code:

```python
import os
import sentry_sdk

sentry_sdk.init(
    dsn=os.environ.get("SENTRY_DSN"),
    # ...
)
```

## Verification

```python
# Intentional error to test
division_by_zero = 1 / 0
```

Or capture manually:

```python
sentry_sdk.capture_message("Test message from Python")
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Errors not appearing | Ensure `init()` is called early, check DSN |
| No traces | Set `traces_sample_rate` > 0 |
| IPython errors not captured | Run from file, not interactive shell |
| Async errors missing | Initialize inside async function |

More Performance skills

seo-audit

coreyhaines31/marketingskills

When the user wants to audit, review, or diagnose SEO issues on their site. Also use when the user mentions "SEO audit," "technical SEO," "why am I not ranking," "SEO issues," "on-page SEO," "meta tags review," "SEO health check," "my traffic dropped," "lost rankings," "not showing up in Google," "site isn't ranking," "Google update hit me," "page speed," "core web vitals," "crawl errors," or "indexing issues." Use this even if the user just says something vague like "my SEO is bad" or "help with SEO" — start with an audit. For building pages at scale to target keywords, see programmatic-seo. For adding structured data, see schema. For AI search optimization, see ai-seo.

195.1k

competitor-profiling

coreyhaines31/marketingskills

When the user wants to research, profile, or analyze competitors from their URLs. Also use when the user mentions 'competitor profile,' 'competitor research,' 'competitor analysis,' 'profile this competitor,' 'analyze competitor,' 'competitive intelligence,' 'competitor deep dive,' 'who are my competitors,' 'competitor landscape,' 'competitor dossier,' 'competitive audit,' or 'research these competitors.' Input is a list of competitor URLs. Output is structured competitor profile markdown files. For creating comparison/alternative pages from profiles, see competitors. For sales-specific battle cards, see sales-enablement.

65.8k

vercel-optimize

vercel-labs/agent-skills

Use for Vercel cost and performance optimization on deployed projects, especially Next.js, SvelteKit, Nuxt, and limited Astro apps. Collect Vercel metrics, usage, project config, and code scan results first; investigate only metric-backed candidates; produce ranked recommendations grounded in verified files and version-aware Vercel/framework docs. Trigger for Vercel bill reduction, slow or expensive routes, caching opportunities, Function Invocations, Build Minutes, Fast Data Transfer, Core Web Vitals, Bot Management, Fluid compute, or cost breakdown requests.

59.3k

← All Performance skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY