Sentry

Setting

SENTRY_DSN (secret)

SDK

sentry-sdk 2.x with the Flask and logging integrations

Code

tools/utils.py (setup_sentry), called by run.py and by with_error_handler

Outside ENV_NAME dev, local and test, setup_sentry() initialises the SDK with environment=ENV_NAME (production, staging). Log records at WARNING and above become Sentry events — provided they pass the root level LOG_LEVEL, which is ERROR in production. Every logger.error / logger.exception in a view or task is therefore reported; warnings only on stage.

Async tasks and the stream handler are wrapped in with_error_handler, which logs the exception with context and re-raises, so the Worker invocation is also marked as failed in CloudWatch.