Class: PSI::Event
- Inherits:
-
Object
- Object
- PSI::Event
- Defined in:
- lib/psi/event.rb
Overview
A pressure event delivered by Monitor.
Instance Attribute Summary collapse
-
#at ⇒ Object
readonly
Returns the value of attribute at.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#reading ⇒ Object
readonly
Returns the value of attribute reading.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#stall ⇒ Object
readonly
Returns the value of attribute stall.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
-
#initialize(trigger:, reading:, at: Time.now) ⇒ Event
constructor
A new instance of Event.
-
#to_s ⇒ String
Formats the pressure and threshold for logs.
Constructor Details
#initialize(trigger:, reading:, at: Time.now) ⇒ Event
Returns a new instance of Event.
8 9 10 11 12 13 14 15 |
# File 'lib/psi/event.rb', line 8 def initialize(trigger:, reading:, at: Time.now) @resource = trigger.resource @kind = trigger.kind @stall = trigger.stall @window = trigger.window @reading = reading @at = at end |
Instance Attribute Details
#at ⇒ Object (readonly)
Returns the value of attribute at.
6 7 8 |
# File 'lib/psi/event.rb', line 6 def at @at end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/psi/event.rb', line 6 def kind @kind end |
#reading ⇒ Object (readonly)
Returns the value of attribute reading.
6 7 8 |
# File 'lib/psi/event.rb', line 6 def reading @reading end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
6 7 8 |
# File 'lib/psi/event.rb', line 6 def resource @resource end |
#stall ⇒ Object (readonly)
Returns the value of attribute stall.
6 7 8 |
# File 'lib/psi/event.rb', line 6 def stall @stall end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
6 7 8 |
# File 'lib/psi/event.rb', line 6 def window @window end |
Instance Method Details
#to_s ⇒ String
Formats the pressure and threshold for logs.
19 20 21 22 23 |
# File 'lib/psi/event.rb', line 19 def to_s average = reading.public_send(kind)&.avg10 value = average ? " avg10=#{average}%" : "" "#{resource} #{kind}#{value} (threshold #{duration(stall)}/#{duration(window)})" end |