Sha256: c1b0dbf3ade680be77c9255df099cc004d35b5895dfa5787830a05671c2834c9
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 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? 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 payload[:mongo_runtime] = (mongo_runtime || 0) + MongoActiveInstrumentation::LogSubscriber.reset_runtime 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.1 | lib/mongo_active_instrumentation/controller_runtime.rb |