Class: ActiveSupport::Notifications::Event
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/notifications/instrumenter.rb |
Class Method Summary
Instance Attribute Summary
Instance Method Summary
- #<<(event)
-
#duration
Returns the difference in milliseconds between when the execution of the event started and when it ended.
- #parent_of?(event) ⇒ Boolean
Constructor Details
.new(name, start, ending, transaction_id, payload) ⇒ Event
# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 58
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
Instance Attribute Details
#children (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 55
attr_reader :name, :time, :transaction_id, :payload, :children
#end (rw)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 56
attr_accessor :end
#name (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 55
attr_reader :name, :time, :transaction_id, :payload, :children
#payload (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 55
attr_reader :name, :time, :transaction_id, :payload, :children
#time (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 55
attr_reader :name, :time, :transaction_id, :payload, :children
#transaction_id (readonly)
[ GitHub ]Instance Method Details
#<<(event)
[ GitHub ]# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 84
def <<(event) @children << event end
#duration
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) ⇒ Boolean
# File 'activesupport/lib/active_support/notifications/instrumenter.rb', line 88
def parent_of?(event) @children.include? event end