Class: Findbug::AlertJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/findbug/alert_job.rb

Overview

AlertJob sends alerts asynchronously.

WHY ASYNC ALERTS?

Alert sending involves:

  • HTTP requests to Slack/Discord webhooks

  • Email delivery (SMTP)

  • Potential network latency

If we did this synchronously during error capture:

  1. Slow alerts would slow down error persistence

  2. Failed alerts would block other alerts

  3. Network issues would impact the persist job

By using a separate job:

  1. PersistJob stays fast

  2. Alerts can retry independently

  3. Network issues are isolated

Instance Method Summary collapse

Instance Method Details

#perform(error_event_id) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'app/jobs/findbug/alert_job.rb', line 30

def perform(error_event_id)
  error_event = Findbug::ErrorEvent.find_by(id: error_event_id)
  return unless error_event

  Findbug::Alerts::Dispatcher.send_alerts(error_event)
rescue ActiveRecord::RecordNotFound
  # Event was deleted, skip alerting
  Findbug.logger.debug("[Findbug] Alert skipped: error event #{error_event_id} not found")
end