Add configurable email notification thresholds and lifecycle events #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add configurable email notification thresholds and lifecycle events
Summary
This PR adds granular control over when error notification emails are sent, reducing noise while ensuring important errors don't go unnoticed. Instead of receiving an email for every single error occurrence, you can now configure notifications based on occurrence milestones, rate thresholds, and lifecycle events (resolved/reopened).
Closes #84
Motivation
In production environments, some errors occur frequently but are non-critical (e.g., external API timeouts that auto-retry). Receiving an email for every occurrence creates alert fatigue. This PR allows teams to:
Features
1. Milestone-based notifications
Send emails only at specific occurrence counts with ordinalized subject lines:
Email subjects:
Set to [] to disable count-based emails entirely, or leave as nil (default) for the current behavior (email every occurrence).
Get alerted when errors occur too frequently:
Sends one email when exactly 30 occurrences happen within a 5-minute window. Prevents spam by only triggering once when the threshold is crossed.
Track when errors are resolved or reopened:
Email subjects:
Usage Examples
Example 1: High-traffic application
Example 2: Small team wanting full visibility
Example 3: Disable count-based emails, only use rate threshold
Backward Compatibility
✅ Fully backward compatible - all new settings default to nil or false, preserving existing behavior:
Existing applications require no configuration changes.
Implementation Details
Testing
Tests cover:
Related
Addresses the use case described in #84 for milestone and lifecycle event notifications.