Class: SidekiqVigil::Alert::DigestEvent
- Inherits:
-
Object
- Object
- SidekiqVigil::Alert::DigestEvent
- Defined in:
- lib/sidekiq_vigil/alert/event.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #alert_id ⇒ Object
- #history ⇒ Object
-
#initialize(events:, timestamp:, limit: 5) ⇒ DigestEvent
constructor
A new instance of DigestEvent.
- #result ⇒ Object
- #severity ⇒ Object
- #state ⇒ Object
- #to_h ⇒ Object
- #transition ⇒ Object
Constructor Details
#initialize(events:, timestamp:, limit: 5) ⇒ DigestEvent
Returns a new instance of DigestEvent.
40 41 42 43 44 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 40 def initialize(events:, timestamp:, limit: 5) @events = events @timestamp = @limit = limit end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
38 39 40 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 38 def events @events end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
38 39 40 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 38 def @timestamp end |
Instance Method Details
#alert_id ⇒ Object
54 55 56 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 54 def alert_id "digest" end |
#history ⇒ Object
68 69 70 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 68 def history [] end |
#result ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 58 def result @result ||= Result.new( check_name: "digest", severity:, value: events.length, message: "#{events.length} alerts in this cycle", metadata: { counts: counts, top: top } ) end |
#severity ⇒ Object
50 51 52 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 50 def severity severities.include?(:critical) || severities.include?(:error) ? :critical : :warn end |
#state ⇒ Object
72 73 74 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 72 def state State.new(status: "firing", severity: severity.to_s) end |
#to_h ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 76 def to_h { schema_version: "1.0", event: "digest", alert_id:, timestamp: .utc.iso8601, counts:, alerts: top } end |
#transition ⇒ Object
46 47 48 |
# File 'lib/sidekiq_vigil/alert/event.rb', line 46 def transition :digest end |