Sha256: cf9a49af5c2aa27d93da60714e71c8589668372f7f9db56d04444c3e99cc8f14
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
require 'active_record/log_subscriber' module ActiveRecordProfiler class LogSubscriber < ActiveRecord::LogSubscriber def sql(event) start_time = Time.now.to_f payload = event.payload duration = event.duration sql_string = payload[:sql] begin collector = ActiveRecordProfiler::Collector.instance loc = collector.call_location_name collector.record_caller_info(loc, duration, sql_string.strip) collector.record_self_info((Time.now.to_f - start_time), 'updating profiler stats') if ActiveRecordProfiler::Collector.profile_self? start_time = Time.now.to_f if collector.should_flush_stats? collector.flush_query_sites_statistics collector.record_self_info((Time.now.to_f - start_time), 'flushing profiler stats') if ActiveRecordProfiler::Collector.profile_self? end rescue Exception => e Rails.logger.error("Caught exception in #{self.class}: #{e} at #{e.backtrace.first}") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active-record-profiler-1.0 | lib/active-record-profiler/log_subscriber.rb |
active-record-profiler-0.1 | lib/active-record-profiler/log_subscriber.rb |