Documentation
Python
pip install retrace-kit, call init, and exceptions become events. Requires Python 3.10+. Core package has zero runtime dependencies.
Install
pip install retrace-kit
Optional framework extras:
pip install retrace-kit[fastapi] or
pip install retrace-kit[django].
PyPI: retrace-kit. Source: sdk-python. Announcement: Python error tracking.
Initialize
import os
from retrace_kit import init
init(api_key=os.environ["RETRACE_KIT_API_KEY"]) api_key is enough. Optional release should come from
importlib.metadata.version — see SDK → Release.
| Option | Default | Notes |
|---|---|---|
api_key | - | Required. Blank key disables sending and logs a warning. |
environment | - | Attached to every event (for example production). |
enabled | True | Set False to keep hooks quiet locally. |
Auto-capture
After init, the SDK installs handlers for uncaught exceptions, threading errors, and
asyncio loop exceptions. Events include userAgent like Python/3.12.0 and tag
runtime:python.
Exception
raise / thread / asyncio
Handler
SDK global hooks
Event
stack, tags, session
Dashboard
issue / incident
Identical crashes inside a 30-second window are deduplicated client-side.
init also sends a session ping. Handled errors:
capture via capture_exception.
FastAPI
import os
from fastapi import FastAPI
from retrace_kit import init
from retrace_kit.integrations.fastapi import setup_fastapi
init(api_key=os.environ["RETRACE_KIT_API_KEY"])
app = FastAPI()
setup_fastapi(app)
Unhandled 5xx and uncaught exceptions become events with route breadcrumbs and the request URL.
Client errors such as HTTPException(404) are not reported.
Django
Add middleware in settings.py:
MIDDLEWARE = [
# ...
"retrace_kit.integrations.django.RetraceKitMiddleware",
] Call init in settings.py or wsgi.py. Unhandled view exceptions become events; Http404 and PermissionDenied are ignored.
Manual capture
from retrace_kit import add_breadcrumb, capture_exception, set_tag, set_user
set_user({"id": "user_123"})
set_tag("plan", "pro")
add_breadcrumb(type="common", name="checkout", value="started")
try:
checkout()
except Exception as error:
capture_exception(error, context={"url": str(request.url)})
FastAPI and Django integrations attach the request URL for you. Elsewhere, pass url in
context so the issue page has a route.
See also breadcrumbs, current user, incidents.
Notes
- Python 3.10+ — typed public API with mypy coverage.
- Zero core deps — framework extras are optional.
- Request URL — FastAPI/Django set it; otherwise pass
urltocapture_exception.
Examples live in the sdk-python repo (examples/).