diff --git a/README.md b/README.md index cef5ddf..f6170b6 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,15 @@ end ``` `append_info_to_payload` is a method from [ActionController::Instrumentation](https://api.rubyonrails.org/classes/ActionController/Instrumentation.html#method-i-append_info_to_payload) +## Configuration + +Configuration is handled by [anyway_config] gem. With it you can load settings from environment variables (upcased and prefixed with `YABEDA_RAILS_`), YAML files, and other sources. See [anyway_config] docs for details. + +| Config key | Type | Default | Description | +| ---------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | +| `apdex_target` | integer | nil | Tolerable time for Apdex in seconds, exposed as gauge if set. | +| `controller_name_case` | symbol | :snake | Defines whether controller name is reported in camel case (:camel) or snake case (:snake). | +| `ignore_actions` | array | [] | array of controller#action strings that should be ignored, controller should be in camel case, example `['HealthCheck::HealthCheckController#index']` | ## Development diff --git a/lib/yabeda/rails.rb b/lib/yabeda/rails.rb index 25af428..b4a4fdc 100644 --- a/lib/yabeda/rails.rb +++ b/lib/yabeda/rails.rb @@ -57,6 +57,8 @@ def install! ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args| event = Yabeda::Rails::Event.new(*args) + next if event.controller_action.in?(config.ignore_actions) + rails_requests_total.increment(event.labels) rails_request_duration.measure(event.labels, event.duration) rails_view_runtime.measure(event.labels, event.view_runtime) diff --git a/lib/yabeda/rails/config.rb b/lib/yabeda/rails/config.rb index 0c10ea5..5d54279 100644 --- a/lib/yabeda/rails/config.rb +++ b/lib/yabeda/rails/config.rb @@ -10,6 +10,7 @@ class Config < ::Anyway::Config attr_config :apdex_target attr_config controller_name_case: :snake + attr_config ignore_actions: [] end end end diff --git a/lib/yabeda/rails/event.rb b/lib/yabeda/rails/event.rb index e991a3f..6bdce4f 100644 --- a/lib/yabeda/rails/event.rb +++ b/lib/yabeda/rails/event.rb @@ -29,6 +29,10 @@ def db_runtime ms2s payload[:db_runtime] end + def controller_action + "#{payload[:controller]}##{payload[:action]}" + end + private def controller