Sha256: 8c0ed8943c60a31b5596b1286d360a3bf75f37a97d62234b9f5e367775186f5f
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
## based off https://github.com/newrelic/rpm/blob/master/lib/new_relic/agent/instrumentation/active_record.rb ## fallback for alls sorts of weird dbs module Rack class MiniProfiler module ActiveRecordInstrumentation def self.included(instrumented_class) instrumented_class.class_eval do unless instrumented_class.method_defined?(:log_without_miniprofiler) alias_method :log_without_miniprofiler, :log alias_method :log, :log_with_miniprofiler protected :log end end end def log_with_miniprofiler(*args, &block) return log_without_miniprofiler(*args, &block) unless SqlPatches.should_measure? sql, name, _binds = args start = Time.now rval = log_without_miniprofiler(*args, &block) # Don't log schema queries if the option is set # return rval unless sql =~ /\"vms\"/ # return rval unless sql =~ /\"(vms|ext_management_systems)\"/ return rval if Rack::MiniProfiler.config.skip_schema_queries and name =~ /SCHEMA/ elapsed_time = SqlPatches.elapsed_time(start) Rack::MiniProfiler.record_sql(sql, elapsed_time) rval end end end def self.insert_instrumentation ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do include ::Rack::MiniProfiler::ActiveRecordInstrumentation end end if defined?(::Rails) && !SqlPatches.patched? insert_instrumentation end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rack-mini-profiler-0.9.9.2 | lib/patches/db/activerecord.rb |
rack-mini-profiler-0.9.9.1 | lib/patches/db/activerecord.rb |
rack-mini-profiler-0.9.9 | lib/patches/db/activerecord.rb |