Set Up Bugsly for FastAPI
Monitor FastAPI applications with automatic request tracing, Pydantic validation error capture, and async endpoint performance monitoring.
1. Install the SDK
pip install sentry-sdk[fastapi]2. Configure Bugsly
Add the following to your application entry point. Replace the DSN with your project DSN from the Bugsly dashboard.
from fastapi import FastAPI
import sentry_sdk
sentry_sdk.init(
dsn="https://your-dsn@bugsly.dev/1",
environment="production",
traces_sample_rate=1.0,
profiles_sample_rate=1.0,
)
app = FastAPI()
@app.get("/")
async def root():
return {"status": "ok"}
# Errors in endpoints are automatically captured
# with full request context and async trace.3. Verify It Works
Trigger a test error in your application and check your Bugsly dashboard. The error should show up as an issue within a few seconds.
Want to check your DSN before touching any code? From a macOS, Linux or WSL terminal, this sends one real error without any SDK (replace your-dsn with the key from your DSN):
curl -sS -X POST "https://bugsly.dev/api/1/envelope/" \
-H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=your-dsn" \
--data-binary $'{}\n{"type":"event"}\n{"level":"error","platform":"other","exception":{"values":[{"type":"CurlTestError","value":"Hello from my terminal"}]}}'Evaluating APM for your API? See how the top Python performance monitoring tools compare.
What You Get with FastAPI
- Automatic ASGI middleware integration
- Pydantic validation error tracking with field details
- Async endpoint performance monitoring
- Dependency injection error capture
- Request/response body capture for debugging
- SQLAlchemy and Tortoise ORM query tracking
Frequently Asked Questions
Does Bugsly capture Pydantic validation errors?
Yes. When a request fails Pydantic validation, Bugsly captures the validation error with details about which fields failed and why, making it easy to debug malformed requests.
How does Bugsly work with FastAPI's async endpoints?
The SDK fully supports async/await in FastAPI. Each request gets its own trace context, and errors in async endpoints include the correct coroutine stack trace.
Can I use Bugsly with FastAPI and SQLAlchemy?
Yes. Install sentry-sdk[sqlalchemy] alongside sentry-sdk[fastapi]. Database queries are automatically recorded as performance spans with query execution time.
Start tracking errors in FastAPI for free
The free plan includes 100 issues per month, 7-day retention and 10 AI requests per month. Paid plans start at $19/mo.
Start Free