lib/tracebin/timer.rb in tracebin-0.0.10 vs lib/tracebin/timer.rb in tracebin-0.0.11

- old
+ new

@@ -1,9 +1,13 @@ require 'tracebin/recorder' require 'tracebin/helpers' module Tracebin + ## + # 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. class Timer include ::Tracebin::Helpers attr_accessor :transaction_name attr_reader :events @@ -13,18 +17,18 @@ @start_time = nil @stop_time = nil end def start! - @start_time = Time.now + @start_time = timestamp_string Recorder.start_recording end def stop! collect_events Recorder.stop_recording - @stop_time = Time.now + @stop_time = timestamp_string end def payload { type: :cycle_transaction, @@ -41,10 +45,10 @@ } } end def duration - to_milliseconds @stop_time - @start_time + milliseconds_between @stop_time, @start_time end def transaction_type 'request_response' end