Class: RailsErrorDashboard::Services::ExceptionFilter
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Services::ExceptionFilter
- Defined in:
- lib/rails_error_dashboard/services/exception_filter.rb
Overview
Pure algorithm: Determine if an exception should be logged
No database access — checks configuration rules against exception data. Used by LogError command to filter exceptions before logging.
Class Method Summary collapse
-
.critical?(exception) ⇒ Boolean
Check if exception is a critical error type.
-
.ignored?(exception) ⇒ Boolean
Check if exception is in the ignored exceptions list Supports both string class names and regex patterns.
-
.sampled_out?(exception) ⇒ Boolean
Check if exception should be skipped due to sampling rate Critical errors are ALWAYS logged regardless of sampling.
-
.should_log?(exception) ⇒ Boolean
Check if an exception should be logged (not ignored, not sampled out).
Class Method Details
.critical?(exception) ⇒ Boolean
Check if exception is a critical error type
64 65 66 |
# File 'lib/rails_error_dashboard/services/exception_filter.rb', line 64 def self.critical?(exception) SeverityClassifier.critical?(exception.class.name) end |
.ignored?(exception) ⇒ Boolean
Check if exception is in the ignored exceptions list Supports both string class names and regex patterns
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rails_error_dashboard/services/exception_filter.rb', line 26 def self.ignored?(exception) ignored_exceptions = RailsErrorDashboard.configuration.ignored_exceptions return false if ignored_exceptions.blank? exception_class_name = exception.class.name ignored_exceptions.any? do |ignored| case ignored when String exception.is_a?(ignored.constantize) when Regexp exception_class_name.match?(ignored) else false end rescue NameError RailsErrorDashboard::Logger.warn("Invalid ignored exception class: #{ignored}") false end end |
.sampled_out?(exception) ⇒ Boolean
Check if exception should be skipped due to sampling rate Critical errors are ALWAYS logged regardless of sampling
51 52 53 54 55 56 57 58 59 |
# File 'lib/rails_error_dashboard/services/exception_filter.rb', line 51 def self.sampled_out?(exception) sampling_rate = RailsErrorDashboard.configuration.sampling_rate return false if sampling_rate >= 1.0 return false if critical?(exception) return true if sampling_rate <= 0.0 rand > sampling_rate end |
.should_log?(exception) ⇒ Boolean
Check if an exception should be logged (not ignored, not sampled out)
16 17 18 19 20 |
# File 'lib/rails_error_dashboard/services/exception_filter.rb', line 16 def self.should_log?(exception) return false if ignored?(exception) return false if sampled_out?(exception) true end |