Class: Octave::Payload
- Inherits:
-
Object
- Object
- Octave::Payload
- Defined in:
- lib/octave/payload.rb
Overview
A Payload contains information about each metric and the time to complete. After each Payload has been completed, it will be sent to each dispatcher.
To manually create a payload and send it to the dispatcher:
payload = Payload.new("name-of-event")
expensive_method
payload.done
Octave.dispatch(payload)
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#done ⇒ Object
Call this method immediately after the work has been completed.
-
#duration ⇒ Object
Duration of the metric in milliseconds.
-
#initialize(name, options = {}) ⇒ Payload
constructor
Creates a new Payload.
Constructor Details
#initialize(name, options = {}) ⇒ Payload
Creates a new Payload.
17 18 19 20 21 |
# File 'lib/octave/payload.rb', line 17 def initialize(name, = {}) @start_time = Time.now @name = name @options = end |
Instance Attribute Details
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
11 12 13 |
# File 'lib/octave/payload.rb', line 11 def end_time @end_time end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/octave/payload.rb', line 11 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/octave/payload.rb', line 11 def @options end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
11 12 13 |
# File 'lib/octave/payload.rb', line 11 def start_time @start_time end |
Instance Method Details
#done ⇒ Object
Call this method immediately after the work has been completed.
24 25 26 |
# File 'lib/octave/payload.rb', line 24 def done @end_time = Time.now end |
#duration ⇒ Object
Duration of the metric in milliseconds.
29 30 31 32 33 |
# File 'lib/octave/payload.rb', line 29 def duration return if end_time.nil? (end_time - start_time) * 1000.0 end |