Class: RailsErrorDashboard::BaselineAlertJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- RailsErrorDashboard::BaselineAlertJob
- Defined in:
- app/jobs/rails_error_dashboard/baseline_alert_job.rb
Overview
Sends baseline anomaly alerts through configured notification channels
This job is triggered when an error exceeds baseline thresholds. It respects cooldown periods to prevent alert fatigue and sends notifications through all enabled channels (Slack, Email, Discord, etc.)
Instance Method Summary collapse
Instance Method Details
#perform(error_log_id, anomaly_data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/jobs/rails_error_dashboard/baseline_alert_job.rb', line 14 def perform(error_log_id, anomaly_data) error_log = ErrorLog.find_by(id: error_log_id) return unless error_log config = RailsErrorDashboard.configuration # Check if we should send alert (cooldown check) unless Services::BaselineAlertThrottler.should_alert?( error_log.error_type, error_log.platform, cooldown_minutes: config.baseline_alert_cooldown_minutes ) Rails.logger.info( "Baseline alert throttled for #{error_log.error_type} on #{error_log.platform}" ) return end # Record that we're sending an alert Services::BaselineAlertThrottler.record_alert( error_log.error_type, error_log.platform ) # Send notifications through all enabled channels send_notifications(error_log, anomaly_data, config) end |