Search code examples
ruby-on-railsruby-on-rails-3actioncontrollernewrelic

How can I monitor an ActionController::Metal with NewRelic?


I have a Rails 3 application of which some controllers are normal rails controllers and some are implemented using ActionController::Metal. By default, NewRelic monitors the normal rails controllers but not the NewRelic ones.

It seems that NewRelic supports Rack applications, but the code examples given are either when there is a specific piece of middleware you want to monitor, or when you have a MetalApp you are defining. Neither seems to work with ActionController::Metal.

So, how do I add NewRelic monitoring to my metal controllers?


Solution

  • New Relic support suggested:

    class SteelController < ActionController::Metal     
      include ActionController::Rendering                 
    
      def show
        render :text => { :data => 1 }.to_json           
      end                     
      include NewRelic::Agent::Instrumentation::ControllerInstrumentation     
      add_transaction_tracer :show     
    
    end 
    

    which seems to work.