Class: ActiveSupport::Notifications::Event
- Defined in:
- lib/active_support/notifications/instrumenter.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#end ⇒ Object
Returns the value of attribute end.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Instance Method Summary collapse
- #<<(event) ⇒ Object
-
#duration ⇒ Object
Returns the difference in milliseconds between when the execution of the event started and when it ended.
-
#initialize(name, start, ending, transaction_id, payload) ⇒ Event
constructor
A new instance of Event.
- #parent_of?(event) ⇒ Boolean
Constructor Details
#initialize(name, start, ending, transaction_id, payload) ⇒ Event
Returns a new instance of Event.
56 57 58 59 60 61 62 63 64 |
# File '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 |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
53 54 55 |
# File 'lib/active_support/notifications/instrumenter.rb', line 53 def children @children end |
#end ⇒ Object
Returns the value of attribute end.
54 55 56 |
# File 'lib/active_support/notifications/instrumenter.rb', line 54 def end @end end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
53 54 55 |
# File 'lib/active_support/notifications/instrumenter.rb', line 53 def name @name end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
53 54 55 |
# File 'lib/active_support/notifications/instrumenter.rb', line 53 def payload @payload end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
53 54 55 |
# File 'lib/active_support/notifications/instrumenter.rb', line 53 def time @time end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
53 54 55 |
# File 'lib/active_support/notifications/instrumenter.rb', line 53 def transaction_id @transaction_id end |
Instance Method Details
#<<(event) ⇒ Object
82 83 84 |
# File 'lib/active_support/notifications/instrumenter.rb', line 82 def <<(event) @children << event end |
#duration ⇒ Object
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
78 79 80 |
# File 'lib/active_support/notifications/instrumenter.rb', line 78 def duration @duration ||= 1000.0 * (self.end - time) end |
#parent_of?(event) ⇒ Boolean
86 87 88 |
# File 'lib/active_support/notifications/instrumenter.rb', line 86 def parent_of?(event) @children.include? event end |