Sha256: 44ae8bf4168ac1bdbfa9ff7db610ab99c7a15a4441a5e2f0b455f686aee9ace9
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true module ActiveRecordQueryCounter # Extension to ActiveRecord::ConnectionAdapters::TransactionManager to count transactions. module TransactionManagerExtension def begin_transaction(*args, **kwargs) if open_transactions == 0 @active_record_query_counter_transaction_start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) end super end def commit_transaction(*args) if @active_record_query_counter_transaction_start_time && open_transactions == 1 end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) ActiveRecordQueryCounter.add_transaction(@active_record_query_counter_transaction_start_time, end_time) @active_record_query_counter_transaction_start_time = nil end super end def rollback_transaction(*args) if @active_record_query_counter_transaction_start_time && open_transactions == 1 end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) ActiveRecordQueryCounter.add_transaction(@active_record_query_counter_transaction_start_time, end_time) @active_record_query_counter_transaction_start_time = nil end super end end end
Version data entries
2 entries across 2 versions & 1 rubygems