Sha256: ff2b92d37928db590329ec9962a1b79eeb192c432dc086bbe0aa286cfa1b48cc
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
require "active_support/core_ext/module/attr_internal" require "active_record/log_subscriber" module MongoActiveInstrumentation module ControllerRuntime #:nodoc: extend ActiveSupport::Concern protected attr_internal :mongo_runtime private def process_action(action, *args) # We also need to reset the runtime before each action # because of queries in middleware or in cases we are streaming # and it won't be cleaned up by the method below. MongoActiveInstrumentation::LogSubscriber.reset_runtime super end def cleanup_view_runtime if logger && logger.info? && ActiveRecord::Base.connected? mongo_rt_before_render = MongoActiveInstrumentation::LogSubscriber.reset_runtime self.mongo_runtime = (mongo_runtime || 0) + mongo_rt_before_render runtime = super mongo_rt_after_render = MongoActiveInstrumentation::LogSubscriber.reset_runtime self.mongo_runtime += mongo_rt_after_render runtime - mongo_rt_after_render else super end end def append_info_to_payload(payload) super if ActiveRecord::Base.connected? payload[:mongo_runtime] = (mongo_runtime || 0) + MongoActiveInstrumentation::LogSubscriber.reset_runtime end end module ClassMethods # :nodoc: def log_process_action(payload) messages, mongo_runtime = super, payload[:mongo_runtime] messages << ("Mongo: %.1fms" % mongo_runtime.to_f) if mongo_runtime messages end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo_active_instrumentation-0.1.0 | lib/mongo_active_instrumentation/controller_runtime.rb |