Flask error tracking
Flask error tracking in one line
Initialize ErrorLens before you create your Flask app and every unhandled exception is reported with its traceback, the request and the route — no extension or error handler to write.
Set up
pip install errorlensimport errorlens
from flask import Flask
errorlens.init(dsn="https://<key>@errorlens.io/<project-id>", traces_sample_rate=0.2)
app = Flask(__name__)
@app.get("/orders/<int:order_id>")
def order(order_id):
return load_order(order_id)What is captured
- Exceptions raised in views, including those Flask turns into 500 responses
- Request method, URL, headers and route (
/orders/<int:order_id>) - Per-request context: users and tags set in one request never leak into another
- Transactions per route with SQLAlchemy query spans and outgoing HTTP calls
- Streaming responses, which are timed until the last chunk is sent
Flask error logging, upgraded
app.logger.exception() still works — ERROR log records become ErrorLens events and lower levels become breadcrumbs. What you gain is grouping, alerts, releases and the request context next to each traceback.
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
Do I need a Flask extension?
No. Calling errorlens.init() before creating the app is enough; the Flask integration is detected automatically.
Does it work with Gunicorn and uWSGI?
Yes. The SDK is fork-safe: its background sender restarts in each worker process.
Keep reading
Python error tracking with tracebacks you can actually debug
Track Python exceptions with full tracebacks, local variables and request context. One line to set up for Django, Flask, FastAPI and Celery. Open source.
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.
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.
Open-source log management linked to your errors and traces
Open-source log management: structured logs from your SDK or OpenTelemetry with search, severity filters, live tail and links to traces. Self-host on Postgres.
Start tracking errors in minutes
Free hosted plan with 5,000 errors a month, or self-host with no limits. No credit card.