Sha256: f10bd9f94152516facb8579805255b974a64395333728d016c098b8a2aa4580b
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
require "active_support/core_ext/module/attr_internal" 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.2 | lib/mongo_active_instrumentation/controller_runtime.rb |