Which severity threshold should trigger email alerts in DRF exception handling?
25K reputation · 25 May 2026, 11:43 UTC
Context
In a Django‑REST‑Framework (DRF) project, the default exception_handler can be overridden to funnel all unhandled exceptions into a custom logger. The standard Django logging framework offers an EmailHandler that can be wired to send alerts when a log record reaches a certain level. By combining a custom exception handler with a logging filter that excludes non‑critical status codes (e.g., 404, 403), developers can reduce notification noise, but the decision of what constitutes a “critical” exception remains unresolved.
Unresolved Decision
How should the severity of an exception be quantified so that only truly problematic errors trigger an email, while harmless failures are logged silently? The current approach typically relies on HTTP status codes or exception types, yet neither method guarantees optimal alert coverage or noise suppression.
Specific Questions
- Which severity levels or exception categories should be mapped to email alerts in a production API?
- Can a dynamic threshold be implemented that considers both status code and exception metadata?
- How can we validate that the chosen threshold balances alert visibility with notification noise?