Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This peers into the private APIs of `ActiveSupport` and `ActionController::LogSubscriber` to check the status of the queued up events for 'process_action.action_controller', and see if any are larger than 10 seconds. If they are, it will report them to the Rails.logger. Usage ----- This can be instrumented in many ways, but the easiest is via config/initializer: # config/initializers/request_watcher.local.rb if ENV['WATCH_FOR_LONG_REQUESTS'] require 'workers/rails_request_monitor' Thread.new do loop do sleep 10 RailsRequestMonitor.log_long_running_requests end end.abort_on_exception = true end And running a development server by running: $ WATCH_FOR_LONG_REQUESTS=1 bin/rails s This will check every 10 seconds, and when long requests are found, they will be output to the Rails.log on level WARN. This can also be instrumented in MiqWebServerRunnerMixin with relative ease: # app/models/mixins/miq_web_server_runner_mixin.rb + + def do_heartbeat_work + RailsRequestMonitor.log_long_running_requests + end Or anywhere that it makes sense (signal handlers, etc.) TODO ---- - Update to 1.minute instead of 10.seconds (for quicker testing) - Tests - Instrument in `MiqWebServerRunnerMixin` (new commit?)
- Loading branch information
Maybe it's not there yet but what's populating the
THREAD_VAR_KEY
thread local variable with the queue? Does rails do that?