Class: ErrorRadar::Configuration
- Inherits:
-
Object
- Object
- ErrorRadar::Configuration
- Defined in:
- lib/error_radar/configuration.rb
Overview
Holds every host-app-specific decision so the engine stays decoupled. Configure from an initializer (see the install generator’s template).
Instance Attribute Summary collapse
-
#authenticate ⇒ Object
Dashboard auth: ‘->(controller) { … }` run as a before_action.
-
#backtrace_lines ⇒ Object
How many backtrace lines to persist.
-
#categorizers ⇒ Object
Custom classification rules.
-
#current_user ⇒ Object
‘->(controller) { “who@acted” }` — stamped onto resolved errors.
-
#detail_extractors ⇒ Object
Extract extra structured columns from custom exception types.
-
#enabled ⇒ Object
Master switch — set false (e.g. in test env) to make capture a no-op.
-
#expected_servers ⇒ Object
Optional Sidekiq process expectations for the dashboard’s server panel.
-
#ignored_exceptions ⇒ Object
Exception class names the Rack middleware must NOT log (expected client outcomes: routing errors, 404s, bad requests, …).
-
#install_middleware ⇒ Object
Integration toggles.
-
#install_rails_admin ⇒ Object
Integration toggles.
-
#install_sidekiq ⇒ Object
Integration toggles.
-
#max_message_length ⇒ Object
Truncate stored messages to this many chars.
-
#sensitive_params ⇒ Object
Request param keys to scrub before persisting them in ‘context`.
Instance Method Summary collapse
-
#categorize(&block) ⇒ Object
Convenience DSL inside ‘configure`: c.categorize { |e| :external_api if e.is_a?(MyApi::Error) }.
-
#extract_details(&block) ⇒ Object
c.extract_details { |e| { http_status: e.status } if e.is_a?(MyApi::Error) }.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/error_radar/configuration.rb', line 46 def initialize @enabled = true @backtrace_lines = 30 @max_message_length = 4_000 @ignored_exceptions = %w[ ActionController::RoutingError ActiveRecord::RecordNotFound ActionController::ParameterMissing ActionController::UnknownFormat ActionController::BadRequest ActionController::InvalidAuthenticityToken ActionDispatch::Http::Parameters::ParseError ] @sensitive_params = %w[password password_confirmation token access_token authorization secret] @install_middleware = true @install_sidekiq = true @install_rails_admin = true @categorizers = [] @detail_extractors = [] @expected_servers = [] @authenticate = nil @current_user = nil end |
Instance Attribute Details
#authenticate ⇒ Object
Dashboard auth: ‘->(controller) { … }` run as a before_action. Raise / redirect inside it to deny access. nil => no auth (NOT recommended in prod).
41 42 43 |
# File 'lib/error_radar/configuration.rb', line 41 def authenticate @authenticate end |
#backtrace_lines ⇒ Object
How many backtrace lines to persist.
11 12 13 |
# File 'lib/error_radar/configuration.rb', line 11 def backtrace_lines @backtrace_lines end |
#categorizers ⇒ Object
Custom classification rules. Each is a callable ‘->(exception) { :category | nil }`. The first rule that returns a non-nil category wins; built-in rules run after.
28 29 30 |
# File 'lib/error_radar/configuration.rb', line 28 def categorizers @categorizers end |
#current_user ⇒ Object
‘->(controller) { “who@acted” }` — stamped onto resolved errors.
44 45 46 |
# File 'lib/error_radar/configuration.rb', line 44 def current_user @current_user end |
#detail_extractors ⇒ Object
Extract extra structured columns from custom exception types. Each is a callable ‘->(exception) { { http_status:, request_url:, api_code:, api_subcode: } | nil }`.
32 33 34 |
# File 'lib/error_radar/configuration.rb', line 32 def detail_extractors @detail_extractors end |
#enabled ⇒ Object
Master switch — set false (e.g. in test env) to make capture a no-op.
8 9 10 |
# File 'lib/error_radar/configuration.rb', line 8 def enabled @enabled end |
#expected_servers ⇒ Object
Optional Sidekiq process expectations for the dashboard’s server panel. Each entry: { key:, name:, tag:, host:, queue_hint: }. Empty => the panel simply lists whatever live processes exist.
37 38 39 |
# File 'lib/error_radar/configuration.rb', line 37 def expected_servers @expected_servers end |
#ignored_exceptions ⇒ Object
Exception class names the Rack middleware must NOT log (expected client outcomes: routing errors, 404s, bad requests, …).
18 19 20 |
# File 'lib/error_radar/configuration.rb', line 18 def ignored_exceptions @ignored_exceptions end |
#install_middleware ⇒ Object
Integration toggles.
24 25 26 |
# File 'lib/error_radar/configuration.rb', line 24 def install_middleware @install_middleware end |
#install_rails_admin ⇒ Object
Integration toggles.
24 25 26 |
# File 'lib/error_radar/configuration.rb', line 24 def install_rails_admin @install_rails_admin end |
#install_sidekiq ⇒ Object
Integration toggles.
24 25 26 |
# File 'lib/error_radar/configuration.rb', line 24 def install_sidekiq @install_sidekiq end |
#max_message_length ⇒ Object
Truncate stored messages to this many chars.
14 15 16 |
# File 'lib/error_radar/configuration.rb', line 14 def @max_message_length end |
#sensitive_params ⇒ Object
Request param keys to scrub before persisting them in ‘context`.
21 22 23 |
# File 'lib/error_radar/configuration.rb', line 21 def sensitive_params @sensitive_params end |
Instance Method Details
#categorize(&block) ⇒ Object
Convenience DSL inside ‘configure`:
c.categorize { |e| :external_api if e.is_a?(MyApi::Error) }
72 73 74 |
# File 'lib/error_radar/configuration.rb', line 72 def categorize(&block) @categorizers << block end |
#extract_details(&block) ⇒ Object
c.extract_details { |e| { http_status: e.status } if e.is_a?(MyApi::Error) }
77 78 79 |
# File 'lib/error_radar/configuration.rb', line 77 def extract_details(&block) @detail_extractors << block end |