Uko
Uko

Reputation: 13386

Add class code to active admin dashboard

Ok, the exact cause is that I want to restrict new relic to gather data from admin interface, so I need to put:

newrelic_ignore

into the classes that shouldn't add new relic tracker. In resources classes of ActiveAdmin I can use

controller do
  newrelic_ignore
end

But in dashboard this won't do.

Do you know how can I add class code to dashboard?

Upvotes: 3

Views: 753

Answers (2)

Rob
Rob

Reputation: 11


You can try:

if defined?(NewRelic)
  Rails.application.config.to_prepare do
    controllers = [ActiveAdmin::BaseController, ActiveAdmin::PageController, ActiveAdmin::ResourceController]
    controllers.each do |controller|
      controller.class_eval do
        newrelic_ignore
      end
    end

    ActiveAdmin.application.namespaces.values.each do |namespace|
      namespace.resources.collect(&:controller).each do |controller|
        controller.class_eval do
          newrelic_ignore
        end
      end
    end
  end
end

Upvotes: 1

Matt Van Horn
Matt Van Horn

Reputation: 1644

I'm not very familiar with active admin, but you could try something like this in an initializer:

Rails.application.config.to_prepare do
  ActiveAdmin::BaseController.class_eval do
    newrelic_ignore
  end
end

Upvotes: 0

Related Questions