module Mongoid::Railties::ControllerRuntime::ControllerExtension
This extension mimics the Rails’ internal method to measure ActiveRecord runtime during request processing. It appends MongoDB runtime value (‘mongoid_runtime`) into payload of instrumentation event `process_action.action_controller`.
Protected Instance Methods
append_info_to_payload(payload)
click to toggle source
Add the measurement to the instrumentation event payload.
Calls superclass method
# File lib/mongoid/railties/controller_runtime.rb, line 35 def append_info_to_payload(payload) super payload[:mongoid_runtime] = (mongoid_runtime || 0) + Collector.reset_runtime end
cleanup_view_runtime()
click to toggle source
Override to collect the measurements.
Calls superclass method
# File lib/mongoid/railties/controller_runtime.rb, line 26 def cleanup_view_runtime mongo_rt_before_render = Collector.reset_runtime runtime = super mongo_rt_after_render = Collector.reset_runtime self.mongoid_runtime = mongo_rt_before_render + mongo_rt_after_render runtime - mongo_rt_after_render end
process_action(action, *args)
click to toggle source
Reset the runtime before each action.
Calls superclass method
# File lib/mongoid/railties/controller_runtime.rb, line 20 def process_action(action, *args) Collector.reset_runtime super end