class ActiveSupport::Notifications::Event

Parent:
Object

Attributes

children[R]
end[RW]
name[R]
payload[R]
time[R]
transaction_id[R]

Public Class Methods

new(name, start, ending, transaction_id, payload) Show source
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 56
def initialize(name, start, ending, transaction_id, payload)
  @name           = name
  @payload        = payload.dup
  @time           = start
  @transaction_id = transaction_id
  @end            = ending
  @children       = []
  @duration       = nil
end

Public Instance Methods

<<(event) Show source
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 82
def <<(event)
  @children << event
end
duration() Show source
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 78
def duration
  @duration ||= 1000.0 * (self.end - time)
end

Returns the difference in milliseconds between when the execution of the event started and when it ended.

ActiveSupport::Notifications.subscribe('wait') do |*args|
  @event = ActiveSupport::Notifications::Event.new(*args)
end

ActiveSupport::Notifications.instrument('wait') do
  sleep 1
end

@event.duration # => 1000.138
parent_of?(event) Show source
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 86
def parent_of?(event)
  @children.include? event
end

© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.