lib/active_support/notifications/instrumenter.rb in activesupport-7.1.3.4 vs lib/active_support/notifications/instrumenter.rb in activesupport-7.1.4
- old
+ new
@@ -102,11 +102,11 @@
SecureRandom.hex(10)
end
end
class Event
- attr_reader :name, :time, :end, :transaction_id
+ attr_reader :name, :transaction_id
attr_accessor :payload
def initialize(name, start, ending, transaction_id, payload)
@name = name
@payload = payload.dup
@@ -117,11 +117,19 @@
@cpu_time_finish = 0.0
@allocation_count_start = 0
@allocation_count_finish = 0
end
- def record
+ def time
+ @time / 1000.0 if @time
+ end
+
+ def end
+ @end / 1000.0 if @end
+ end
+
+ def record # :nodoc:
start!
begin
yield payload if block_given?
rescue Exception => e
payload[:exception] = [e.class.name, e.message]
@@ -193,10 +201,10 @@
# sleep 1
# end
#
# @event.duration # => 1000.138
def duration
- self.end - time
+ @end - @time
end
private
def now
Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond)