Class: Technologic::Event
- Inherits:
-
Object
- Object
- Technologic::Event
- Includes:
- ShortCircuIt
- Defined in:
- lib/technologic/event.rb
Constant Summary collapse
- LOGGABLE_DURATION_THRESHOLD_MS =
0.04
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(name, started, finished, payload) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(name, started, finished, payload) ⇒ Event
Returns a new instance of Event.
11 12 13 14 15 |
# File 'lib/technologic/event.rb', line 11 def initialize(name, started, finished, payload) @name = name @duration = finished - started @payload = payload end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
9 10 11 |
# File 'lib/technologic/event.rb', line 9 def duration @duration end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/technologic/event.rb', line 9 def name @name end |
Instance Method Details
#data ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/technologic/event.rb', line 17 def data duration_in_ms = duration * 1000 {}.tap do |hash| hash.merge!(@payload) hash[:event] = name hash[:duration] = ConfigOptions.log_duration_in_ms ? duration_in_ms : duration if duration_in_ms > LOGGABLE_DURATION_THRESHOLD_MS end end |