class Tracebin::Timer
This is the timer for a top-level transaction. Transactions include request/response cycles, as well as background jobs. Background jobs subclass this class and overwrite the #transaction_type
method.
Attributes
events[R]
transaction_name[RW]
Public Class Methods
new(transaction_name = nil)
click to toggle source
# File lib/tracebin/timer.rb, line 15 def initialize(transaction_name = nil) @transaction_name = transaction_name @start_time = nil @stop_time = nil end
Public Instance Methods
duration()
click to toggle source
# File lib/tracebin/timer.rb, line 49 def duration milliseconds_between @stop_time, @start_time end
payload()
click to toggle source
# File lib/tracebin/timer.rb, line 32 def payload { type: :cycle_transaction, data: { transaction_type: transaction_type, name: @transaction_name, start: @start_time, stop: @stop_time, duration: duration, events: @events } } end
start!()
click to toggle source
# File lib/tracebin/timer.rb, line 21 def start! @start_time = timestamp_string Recorder.start_recording end
stop!()
click to toggle source
# File lib/tracebin/timer.rb, line 26 def stop! collect_events Recorder.stop_recording @stop_time = timestamp_string end
transaction_type()
click to toggle source
# File lib/tracebin/timer.rb, line 53 def transaction_type 'request_response' end
Private Instance Methods
collect_events()
click to toggle source
# File lib/tracebin/timer.rb, line 59 def collect_events @events = Recorder.events end