retrace-kit
Lightweight error tracking for Python.
Catch exceptions, attach context, and send them to Retrace Kit.
Features
- Auto-capture uncaught exceptions, threading errors, and asyncio loop exceptions
- Manual reporting with
capture_exception - Breadcrumbs, user context, and tags
- FastAPI and Django integrations
- Zero runtime dependencies in the core package
- Typed public API (Python 3.10+)
Install
pip install retrace-kit
Optional framework integrations:
pip install retrace-kit[fastapi]
pip install retrace-kit[django]
Python
import os
from retrace_kit import init
init(
api_key=os.environ["RETRACE_KIT_API_KEY"],
endpoint=os.environ.get(
"RETRACE_KIT_ENDPOINT",
"https://api.retracekit.cloud/api/error-events",
),
server_url=os.environ.get("RETRACE_KIT_SERVER_URL"),
environment=os.environ.get("RETRACE_KIT_ENVIRONMENT"),
release=os.environ.get("RETRACE_KIT_RELEASE"),
)
Requires Python 3.10+.
Uncaught errors in the main thread, worker threads, and the asyncio event loop are reported automatically after init.
Details: Python docs (coming soon)
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 server errors (5xx and uncaught exceptions) are reported with route breadcrumbs and request URL.
Client errors such as HTTPException(404) are not reported.
See examples/fastapi_app/main.py.
Django
Add middleware to settings.py:
MIDDLEWARE = [
# ...
"retrace_kit.integrations.django.RetraceKitMiddleware",
]
Initialize the SDK in settings.py or wsgi.py:
import os
from retrace_kit import init
init(api_key=os.environ["RETRACE_KIT_API_KEY"])
Unhandled view exceptions are captured; Http404 and PermissionDenied are ignored.
See examples/django_app/.
API
| Export | Description |
|---|---|
init |
Initialize with API key and options |
capture_exception |
Report handled errors |
add_breadcrumb |
Add context before an error |
set_user |
Attach a user id |
set_tag |
Set a key/value tag |
install_asyncio_handler |
Install asyncio loop exception handler |
setup_fastapi |
Register FastAPI exception handlers (retrace_kit.integrations.fastapi) |
RetraceKitMiddleware |
Django middleware (retrace_kit.integrations.django) |
import os
from retrace_kit import (
add_breadcrumb,
capture_exception,
init,
set_tag,
set_user,
)
init(
api_key=os.environ["RETRACE_KIT_API_KEY"],
environment="production",
release="1.2.3",
)
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)
Documentation
https://retracekit.cloud/docs/
Repository: github.com/RetraceKit/sdk-python
Development
pip install -e ".[dev,fastapi,django]"
pytest
ruff check src tests
mypy src/retrace_kit
python -m build
License
Apache-2.0
Release files for retrace-kit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| retrace_kit-0.1.0.tar.gz | 438.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| retrace_kit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 458.7 kB
Release files / retrace_kit-0.1.0.tar.gz
| Download URL | retrace_kit-0.1.0.tar.gz |
|---|---|
| Size | 438.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1d5a94a1f3d992686320ee20e86bb45c022f13abca0e74cc08f0418f97cb68e
|
|
BLAKE2b-256 checksum How to use checksums |
03ab2688e43fef2ca7a257b33682b14b81f8ac285d9b4b7ab1a5897a757d1f6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / retrace_kit-0.1.0-py3-none-any.whl
| Download URL | retrace_kit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b31cfdf39259efc67663788a48d3fbd7cd47c419a4e9f9bef7925b3117d3667c
|
|
BLAKE2b-256 checksum How to use checksums |
d6507aa42456c0a8893501f82efa49164c3f7113c995a6f6151efc3bb289199a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency log