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. You should see the error appear within seconds, complete with stack trace, breadcrumbs, and AI-powered analysis.
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
Get AI-powered error analysis, session replay, and performance monitoring — included free on every plan.
Start Free