class Octave::Payload

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)

Attributes

end_time[R]
name[R]
options[R]
start_time[R]

Public Class Methods

new(name, options = {}) click to toggle source

Creates a new Payload.

@param name [String] The name of the metric @param options [Hash] Hash containing options. Useful for passing to dispatchers

# File lib/octave/payload.rb, line 17
def initialize(name, options = {})
  @start_time = Time.now
  @name       = name
  @options    = options
end

Public Instance Methods

done() click to toggle source

Call this method immediately after the work has been completed.

# File lib/octave/payload.rb, line 24
def done
  @end_time = Time.now
end
duration() click to toggle source

Duration of the metric in milliseconds.

# File lib/octave/payload.rb, line 29
def duration
  return if end_time.nil?

  (end_time - start_time) * 1000.0
end