Class: ActiveRecordQueryCounter::TransactionInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_query_counter/transaction_info.rb

Overview

Data structure for storing information about a transaction. Note that the start and end times are monotonic time and not wall clock time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_time:, end_time:, trace:) ⇒ TransactionInfo



9
10
11
12
13
# File 'lib/active_record_query_counter/transaction_info.rb', line 9

def initialize(start_time:, end_time:, trace:)
  @start_time = start_time
  @end_time = end_time
  @trace = trace
end

Instance Attribute Details

#end_timeObject (readonly)

Returns the value of attribute end_time.



7
8
9
# File 'lib/active_record_query_counter/transaction_info.rb', line 7

def end_time
  @end_time
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



7
8
9
# File 'lib/active_record_query_counter/transaction_info.rb', line 7

def start_time
  @start_time
end

#traceObject (readonly)

Returns the value of attribute trace.



7
8
9
# File 'lib/active_record_query_counter/transaction_info.rb', line 7

def trace
  @trace
end

Instance Method Details

#elapsed_timeFloat

Return the time spent in the transaction.



18
19
20
# File 'lib/active_record_query_counter/transaction_info.rb', line 18

def elapsed_time
  end_time - start_time
end