Don't ignore NewRelic in rails_admin

What to do if you want to debug queries on RailsAdmin, maybe one of your Admin sections is taking longer, as it should be and you don't know what's going on.

Then after you Aha! moment, you think that newrelic can help you out and give you some input on why is taking so long?

That happen to me once, using this RailsAdmin version:

gem 'rails_admin', '~> 0.6.7'  

But after some attempts, I was not able to log my RailsAdmin section on newrelic in my local environment, so looking through the internet I found that my RailsAdmin gem was ignoring newrelic by default.

class ApplicationController < Config.parent_controller.constantize  
    newrelic_ignore if defined?(NewRelic)

    before_filter :_authenticate!
    before_filter :_authorize!
    before_filter :_audit!
...

So, you have some ways to solve this situation.

Solution #1: Use the newest version of RailsAdmin, which for me wasn't the option to choose.

Solution #2: Comment the line and there you go!, now you are tracking RailsAdmin on new relic.

But, How?

$ bundle open rails_admin

Once your editor of preference is open:

Go to app/controllers/rails_admin/application_controller.rb

Comment the newrelic_ignore line:

class ApplicationController < Config.parent_controller.constantize  
    #newrelic_ignore if defined?(NewRelic)

    before_filter :_authenticate!
    before_filter :_authorize!
    before_filter :_audit!
...

Then turn off, and on your rails server:

$ rails s

Reload the browser & go to localhost:3000/newrelic

Now you are able to see the annoying queries that are killing your app.

ProTip: After you hunt and address your issue, don't forget to uncomment the line from your rails_admin gem.

And that's all folks!

Fixed on Oct 4, 2015: https://github.com/sferik/rails_admin/pull/2402/files

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Software Engineer at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!