Back to list
getsentry

sentry-python-setup

by getsentry

4🍴 0📅 Jan 23, 2026

SKILL.md


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 for Python applications, Django, Flask, FastAPI.

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)

Install

pip install sentry-sdk

Configure

Initialize as early as possible in your application:

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:

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

Django

# settings.py
import sentry_sdk

sentry_sdk.init(
    dsn="YOUR_SENTRY_DSN",
    send_default_pii=True,
    traces_sample_rate=1.0,
    enable_logs=True,
)

Flask

from flask import Flask
import sentry_sdk

sentry_sdk.init(
    dsn="YOUR_SENTRY_DSN",
    send_default_pii=True,
    traces_sample_rate=1.0,
    enable_logs=True,
)

app = Flask(__name__)

FastAPI

from fastapi import FastAPI
import sentry_sdk

sentry_sdk.init(
    dsn="YOUR_SENTRY_DSN",
    send_default_pii=True,
    traces_sample_rate=1.0,
    enable_logs=True,
)

app = FastAPI()

Configuration Options

OptionDescriptionDefault
dsnSentry DSNRequired
send_default_piiInclude user dataFalse
traces_sample_rate% of transactions traced0
profile_session_sample_rate% of sessions profiled0
enable_logsSend logs to SentryFalse
environmentEnvironment nameAuto-detected
releaseRelease versionAuto-detected

Environment Variables

SENTRY_DSN=https://xxx@o123.ingest.sentry.io/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project

Or use in code:

import os
import sentry_sdk

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

Verification

# Intentional error to test
division_by_zero = 1 / 0

Or capture manually:

sentry_sdk.capture_message("Test message from Python")

Troubleshooting

IssueSolution
Errors not appearingEnsure init() is called early, check DSN
No tracesSet traces_sample_rate > 0
IPython errors not capturedRun from file, not interactive shell
Async errors missingInitialize inside async function

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon