Official Sentry error monitoring and performance Python SDK. Current version: 2.56.0 (Mar 2026). v2.0 (Jan 2024) removed the Hub class entirely — all Hub-based patterns are broken. Scope API replaced Hub. Integrations (Django, FastAPI, Celery, etc.) must be explicitly imported and passed. traces_sample_rate must be set to enable performance monitoring — omitting it means zero traces sent. enable_tracing deprecated in favor of traces_sample_rate.
pip install sentry-sdkVerified import paths — ran on the pinned version, not inferred.
Sentry Python SDK — error capture, context, and performance tracing.
Replace Hub.current.configure_scope() with sentry_sdk.new_scope(). Replace Hub.current.capture_exception() with sentry_sdk.capture_exception().
Replace enable_tracing=True with traces_sample_rate=1.0
Add traces_sample_rate=0.1 (10%) for production or traces_sample_rate=1.0 for development.
before_send must return the event dict to send it. Return None only when intentionally filtering.
span.set_data('key', value) instead of span.set_measurement('key', value)Call sentry_sdk.init() at the very top of your entry point, before importing framework app objects.
Initialize at module level before app creation, not inside async startup handlers.
Ensure the DSN string passed to `sentry_sdk.init()` is a complete and valid Sentry DSN, replacing any placeholders with their actual values obtained from your Sentry project settings.
Replace all DSN placeholders (PROJECT_ID, KEY, oNNN) with the actual values obtained from your Sentry project settings. Ensure the DSN is a valid URL.