Class: RailsErrorDashboard::StormNotificationJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- RailsErrorDashboard::StormNotificationJob
- Defined in:
- app/jobs/rails_error_dashboard/storm_notification_job.rb
Overview
Sends the SINGLE “error storm in progress” notification per storm episode.
During a storm, per-error notifications are suppressed (500 Slack pings help nobody) — this one message replaces them. The gate guarantees at most one enqueue per episode; this job just delivers.
Instance Method Summary collapse
Instance Method Details
#perform(started_at:, state: "shedding") ⇒ 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 |
# File 'app/jobs/rails_error_dashboard/storm_notification_job.rb', line 14 def perform(started_at:, state: "shedding") config = RailsErrorDashboard.configuration = (started_at, state, config) if config.enable_slack_notifications && config.slack_webhook_url.present? post_json(config.slack_webhook_url, { text: }) end if config.enable_discord_notifications && config.discord_webhook_url.present? post_json(config.discord_webhook_url, { content: }) end if config.enable_webhook_notifications && config.webhook_urls.any? payload = { event: "error_storm_detected", started_at: started_at, state: state, application: app_name(config) } config.webhook_urls.each { |url| post_json(url, payload) } end rescue => e Rails.logger.error("[RailsErrorDashboard] StormNotificationJob failed: #{e.class} - #{e.}") end |