Railties is inserting MiniProfiler too late in the chain


#1

For my app railsties is inserting MiniProfiler way too late in the chain:

Here is my output for rake middleware

use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0xb7c7bac>
use Rack::Runtime
use Rack::MethodOverride
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::RemoteIp
use Rack::Sendfile
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use ActionDispatch::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
use Sass::Plugin::Rack
use Rack::MiniProfiler
run MyBlog::Application.routes

MiniProfiler should be as early as possible so it can profile the various rack filters as well.


#2

I was able to insert the instrumentation earlier, see commit: c455ab1

I tried to move it higher but it stopped showing up on AJAX requests and such, presumably due to rack dependencies that were required.