Class: RailsErrorDashboard::Queries::SwallowedExceptionSummary
- Inherits:
-
Object
- Object
- RailsErrorDashboard::Queries::SwallowedExceptionSummary
- Defined in:
- lib/rails_error_dashboard/queries/swallowed_exception_summary.rb
Overview
Query: Aggregate swallowed exception data across hourly buckets for dashboard display.
Groups by (exception_class, raise_location) and sums raise/rescue counts across all rescue_locations and time buckets. This is important because the tracker stores raise events (rescue_location=nil) and rescue events (rescue_location set) in separate rows — grouping by rescue_location too would prevent the ratio from ever being computed. Filters to entries with rescue_ratio >= threshold (i.e., likely swallowed). Returns array of hashes sorted by total rescue count descending.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(days = 30, application_id: nil) ⇒ SwallowedExceptionSummary
constructor
A new instance of SwallowedExceptionSummary.
Constructor Details
#initialize(days = 30, application_id: nil) ⇒ SwallowedExceptionSummary
Returns a new instance of SwallowedExceptionSummary.
18 19 20 21 22 23 |
# File 'lib/rails_error_dashboard/queries/swallowed_exception_summary.rb', line 18 def initialize(days = 30, application_id: nil) @days = days @application_id = application_id @start_date = days.days.ago.beginning_of_hour @threshold = RailsErrorDashboard.configuration.swallowed_exception_threshold end |
Class Method Details
.call(days = 30, application_id: nil) ⇒ Object
14 15 16 |
# File 'lib/rails_error_dashboard/queries/swallowed_exception_summary.rb', line 14 def self.call(days = 30, application_id: nil) new(days, application_id: application_id).call end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rails_error_dashboard/queries/swallowed_exception_summary.rb', line 25 def call entries = aggregated_entries { entries: entries, summary: { total_swallowed_classes: entries.map { |e| e[:exception_class] }.uniq.size, total_rescue_count: entries.sum { |e| e[:rescue_count] }, total_raise_count: entries.sum { |e| e[:raise_count] } } } rescue => e Rails.logger.error("[RailsErrorDashboard] SwallowedExceptionSummary failed: #{e.class}: #{e.}") { entries: [], summary: { total_swallowed_classes: 0, total_rescue_count: 0, total_raise_count: 0 } } end |