Class: SidekiqVigil::Alert::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_vigil/alert/manager.rb

Constant Summary collapse

HISTORY_TTL =
24 * 60 * 60

Instance Method Summary collapse

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