FastAPI error tracking
FastAPI error tracking built for async
ErrorLens reports unhandled exceptions from FastAPI and Starlette with the request and route, keeps context separate between concurrent async requests, and traces each endpoint's latency.
Set up
pip install errorlensimport errorlens
from fastapi import FastAPI
errorlens.init(dsn="https://<key>@errorlens.io/<project-id>", traces_sample_rate=0.2)
app = FastAPI()
@app.get("/items/{item_id}")
async def read_item(item_id: int):
return await fetch_item(item_id)Built for async Python
- Context lives in
contextvars, so tags and users stay with their own request acrossawaits - Transactions are named after the route template —
GET /items/{item_id}— so every item ID groups together - httpx calls become spans and carry a
traceparentheader to the next service - Validation errors (4xx) are not reported as errors; server errors are
Privacy
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 it work with Starlette apps without FastAPI?
Yes. The integration hooks Starlette itself, so plain Starlette apps and other frameworks built on it are covered.
How do I trace background work?
Wrap it in errorlens.start_transaction(...) and errorlens.start_span(...), or move it to Celery, whose tasks are traced automatically.
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.
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.
An open-source backend for your OpenTelemetry traces and logs
An open-source OpenTelemetry backend: send traces and logs over OTLP/HTTP and get trace waterfalls, latency percentiles, log search and alerts. Self-host free.
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.
Start tracking errors in minutes
Free hosted plan with 5,000 errors a month, or self-host with no limits. No credit card.