Search code examples
ruby-on-railsrubyconfigurationprofiler

How can I ignore many endpoints in Skylight?


Skylight allows you to ignore a list of endpoints by specifying them in your skylight.yml (see Ignoring heartbeat endpoints). But this list doesn't support wildcards and I have a lot of endpoints I want to ignore-- what should I do?


Solution

  • Here's one solution-- create a Rake task to dynamically generate the list of endpoints you want to ignore:

    task generate_ignored_endpoints_list_for_skylight: :environment do
      Rails.application.eager_load!
      ParentController.descendants.flat_map do |controller_class|
        controller_class.action_methods.map do |method_name|
          "#{controller_class.name}##{method_name}"
        end
      end.each do |name|
        puts name
      end
    end
    

    This will work well if the endpoints you want to ignore are grouped under a parent controller (e.g. Admin::ApplicationController if you're using Administrate).