Python error tracking
Python error tracking with tracebacks you can actually debug
The errorlens package reports every unhandled exception in your Python app with the full traceback, the source around each frame, the local variables at the moment it failed, and the request that triggered it.
Install and initialize
The package has no dependencies and supports Python 3.9 and newer. Call init once, as early as possible:
pip install errorlensimport errorlens
errorlens.init(
dsn="https://<key>@errorlens.io/<project-id>",
release="[email protected]",
traces_sample_rate=0.2, # optional: performance tracing
enable_logs=True, # optional: send logs too
)Detected automatically
There is no extra setup for the libraries you already use. When they're installed, ErrorLens hooks into them:
- Django, Flask, FastAPI and Starlette — errors, request data and route-named transactions
- Celery — task failures, with traces that continue from the code that queued the task
- SQLAlchemy and Django ORM — query spans; httpx,
requests/urllib— outgoing request spans and breadcrumbs - The standard
loggingmodule — ERROR records become events, lower levels become breadcrumbs - Threads and uncaught exceptions in scripts
Report handled errors and add context
try:
charge(order)
except PaymentError:
errorlens.capture_exception() # the current exception
errorlens.set_user({"id": user.id})
errorlens.set_tag("plan", "pro")
errorlens.add_breadcrumb(category="payment", message="Charging card")Python logging vs. error tracking
logging.exception() writes a traceback to a file and stops there. ErrorLens keeps your logging setup and adds what logs can't: identical exceptions grouped into one issue, a count of affected users, the release that introduced it, and an alert the first time it happens.
Passwords, tokens, API keys, cookies and card numbers are removed in your app and again on the server before anything is stored — see data scrubbing.
Frequently asked questions
Does the SDK slow my Python app down?
Events are serialized and sent on a background thread with a bounded queue, so request handling never waits on the network. Tracing is off unless you set traces_sample_rate.
Can I see local variables in tracebacks?
Yes. Local variables are captured for frames in your own code (include_local_variables, on by default), with secrets such as passwords and tokens filtered out.
Does it work with async code?
Yes. Context is stored per request and per task using contextvars, so asyncio apps such as FastAPI keep users and tags separate between concurrent requests.
Keep reading
Django error tracking without the 500-error email flood
Catch Django 500 errors with full tracebacks, request data, users and slow queries. Grouped issues and instant alerts instead of ADMINS emails. Open source.
FastAPI error tracking built for async
Track FastAPI and Starlette exceptions with route-named traces, async-safe request context and query spans. One-line setup, open source, self-hostable.
Celery task monitoring that connects jobs to the request that queued them
Monitor Celery tasks: failures with tracebacks, task durations, traces that follow a job from the web request that queued it, and alerts for missed beat jobs.
Open-source APM that links slow requests to their errors and logs
Open-source application performance monitoring: p50/p95 latency, throughput, failure rate and distributed traces linked to errors and logs. Self-host free.
Start tracking errors in minutes
Free hosted plan with 5,000 errors a month, or self-host with no limits. No credit card.