简体   繁体   中英

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?


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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM