Errors, health & alerting

Don't let exceptions die quietly in a log line

An uncaught exception logged as one text line is easy to lose โ€” it scrolls past, and nobody sees it until a user complains. Sentry (and similar error-tracking tools) captures each exception as its own event: the full stack trace, the request that triggered it, any breadcrumbs (recent log lines / actions) leading up to it, and groups repeats of the same error together so you see "this crash happened 400 times today" instead of 400 separate log lines to sift through.

sentry_sdk.init(dsn=..., traces_sample_rate=...) once at startup is most of the setup โ€” the FastAPI/Starlette integration activates automatically once sentry-sdk sees FastAPI installed, capturing unhandled exceptions without you writing a try/except around every route. traces_sample_rate controls what fraction of requests also get performance tracing data sent to Sentry (1.0 = 100%, expensive at scale; a small fraction like 0.1 is typical in production).