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 errorlens
import 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 logging module — 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.

Start tracking errors in minutes

Free hosted plan with 5,000 errors a month, or self-host with no limits. No credit card.