Class: SidekiqVigil::Alert::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result:, transition:, state:, history:, timestamp:) ⇒ Event

Returns a new instance of Event.



8
9
10
11
12
13
14
# File 'lib/sidekiq_vigil/alert/event.rb', line 8

def initialize(result:, transition:, state:, history:, timestamp:)
  @result = result
  @transition = transition.to_sym
  @state = state
  @history = history
  @timestamp = timestamp
end

Instance Attribute Details

#historyObject (readonly)

Returns the value of attribute history.



6
7
8
# File 'lib/sidekiq_vigil/alert/event.rb', line 6

def history
  @history
end

#resultObject (readonly)

Returns the value of attribute result.



6
7
8
# File 'lib/sidekiq_vigil/alert/event.rb', line 6

def result
  @result
end

#stateObject (readonly)

Returns the value of attribute state.



6
7
8
# File 'lib/sidekiq_vigil/alert/event.rb', line 6

def state
  @state
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/sidekiq_vigil/alert/event.rb', line 6

def timestamp
  @timestamp
end

#transitionObject (readonly)

Returns the value of attribute transition.



6
7
8
# File 'lib/sidekiq_vigil/alert/event.rb', line 6

def transition
  @transition
end

Instance Method Details

#alert_idObject



20
21
22
# File 'lib/sidekiq_vigil/alert/event.rb', line 20

def alert_id
  result.alert_id
end

#severityObject



16
17
18
# File 'lib/sidekiq_vigil/alert/event.rb', line 16

def severity
  result.severity
end

#to_hObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sidekiq_vigil/alert/event.rb', line 24

def to_h
  {
    schema_version: "1.0",
    event: transition,
    alert_id:,
    timestamp: timestamp.utc.iso8601,
    alert: result.to_h,
    state: state.to_h,
    history:
  }
end