Class: SidekiqVigil::Alert::Manager
- Inherits:
-
Object
- Object
- SidekiqVigil::Alert::Manager
- Defined in:
- lib/sidekiq_vigil/alert/manager.rb
Constant Summary collapse
- HISTORY_TTL =
24 * 60 * 60
Instance Method Summary collapse
-
#initialize(storage:, config:, mute:, clock: -> { Time.now }) ⇒ Manager
constructor
A new instance of Manager.
- #process(results) ⇒ Object
Constructor Details
#initialize(storage:, config:, mute:, clock: -> { Time.now }) ⇒ Manager
Returns a new instance of Manager.
11 12 13 14 15 16 |
# File 'lib/sidekiq_vigil/alert/manager.rb', line 11 def initialize(storage:, config:, mute:, clock: -> { Time.now }) @storage = storage @config = config @mute = mute @clock = clock end |
Instance Method Details
#process(results) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/sidekiq_vigil/alert/manager.rb', line 18 def process(results) persisted = storage.hash_get_all("alerts") active_ids = results.map(&:alert_id) muted = mute.active? events = results.filter_map { |result| process_result(result, persisted, muted) } prune(persisted.keys - active_ids) Grouping.apply(events, threshold: config.group_threshold, timestamp: now, limit: config.group_top_n) end |