Module: RailsErrorDashboard

Defined in:
lib/rails_error_dashboard/error_reporter.rb,
lib/rails_error_dashboard.rb,
lib/rails_error_dashboard/engine.rb,
lib/rails_error_dashboard/logger.rb,
lib/rails_error_dashboard/plugin.rb,
lib/rails_error_dashboard/version.rb,
lib/rails_error_dashboard/configuration.rb,
lib/rails_error_dashboard/plugin_registry.rb,
app/models/rails_error_dashboard/error_log.rb,
app/models/rails_error_dashboard/application.rb,
lib/rails_error_dashboard/commands/log_error.rb,
lib/rails_error_dashboard/queries/mttr_stats.rb,
lib/rails_error_dashboard/commands/mute_error.rb,
lib/rails_error_dashboard/configuration_error.rb,
lib/rails_error_dashboard/queries/errors_list.rb,
app/jobs/rails_error_dashboard/application_job.rb,
app/models/rails_error_dashboard/error_comment.rb,
app/jobs/rails_error_dashboard/create_issue_job.rb,
app/mailers/rails_error_dashboard/digest_mailer.rb,
app/models/rails_error_dashboard/error_baseline.rb,
lib/rails_error_dashboard/commands/assign_error.rb,
lib/rails_error_dashboard/commands/create_issue.rb,
lib/rails_error_dashboard/commands/snooze_error.rb,
lib/rails_error_dashboard/commands/unmute_error.rb,
lib/rails_error_dashboard/manual_error_reporter.rb,
app/models/rails_error_dashboard/cascade_pattern.rb,
app/models/rails_error_dashboard/diagnostic_dump.rb,
lib/rails_error_dashboard/commands/resolve_error.rb,
lib/rails_error_dashboard/plugins/metrics_plugin.rb,
lib/rails_error_dashboard/queries/baseline_stats.rb,
lib/rails_error_dashboard/queries/error_cascades.rb,
lib/rails_error_dashboard/queries/filter_options.rb,
lib/rails_error_dashboard/queries/similar_errors.rb,
lib/rails_error_dashboard/services/crash_capture.rb,
app/helpers/rails_error_dashboard/overview_helper.rb,
app/jobs/rails_error_dashboard/baseline_alert_job.rb,
app/models/rails_error_dashboard/error_occurrence.rb,
lib/rails_error_dashboard/commands/unassign_error.rb,
lib/rails_error_dashboard/commands/unsnooze_error.rb,
lib/rails_error_dashboard/middleware/rate_limiter.rb,
lib/rails_error_dashboard/queries/analytics_stats.rb,
lib/rails_error_dashboard/queries/critical_alerts.rb,
lib/rails_error_dashboard/queries/dashboard_stats.rb,
lib/rails_error_dashboard/services/cache_analyzer.rb,
lib/rails_error_dashboard/services/curl_generator.rb,
lib/rails_error_dashboard/services/digest_builder.rb,
app/helpers/rails_error_dashboard/backtrace_helper.rb,
app/models/rails_error_dashboard/error_logs_record.rb,
lib/rails_error_dashboard/commands/upsert_baseline.rb,
lib/rails_error_dashboard/middleware/error_catcher.rb,
lib/rails_error_dashboard/plugins/audit_log_plugin.rb,
lib/rails_error_dashboard/queries/recurring_issues.rb,
lib/rails_error_dashboard/queries/release_timeline.rb,
lib/rails_error_dashboard/services/rspec_generator.rb,
app/helpers/rails_error_dashboard/user_agent_helper.rb,
app/jobs/rails_error_dashboard/scheduled_digest_job.rb,
lib/rails_error_dashboard/queries/error_correlation.rb,
lib/rails_error_dashboard/services/backtrace_parser.rb,
lib/rails_error_dashboard/services/cascade_detector.rb,
lib/rails_error_dashboard/services/coverage_tracker.rb,
lib/rails_error_dashboard/services/error_normalizer.rb,
lib/rails_error_dashboard/services/exception_filter.rb,
lib/rails_error_dashboard/services/git_blame_reader.rb,
lib/rails_error_dashboard/services/pattern_detector.rb,
app/helpers/rails_error_dashboard/application_helper.rb,
app/jobs/rails_error_dashboard/retention_cleanup_job.rb,
app/mailers/rails_error_dashboard/application_mailer.rb,
app/models/rails_error_dashboard/swallowed_exception.rb,
lib/rails_error_dashboard/commands/add_error_comment.rb,
lib/rails_error_dashboard/commands/batch_mute_errors.rb,
lib/rails_error_dashboard/queries/job_health_summary.rb,
lib/rails_error_dashboard/queries/n_plus_one_summary.rb,
lib/rails_error_dashboard/services/error_broadcaster.rb,
lib/rails_error_dashboard/services/platform_detector.rb,
app/jobs/rails_error_dashboard/close_linked_issue_job.rb,
lib/rails_error_dashboard/helpers/user_model_detector.rb,
lib/rails_error_dashboard/queries/co_occurring_errors.rb,
lib/rails_error_dashboard/queries/platform_comparison.rb,
lib/rails_error_dashboard/queries/rack_attack_summary.rb,
lib/rails_error_dashboard/queries/user_impact_summary.rb,
lib/rails_error_dashboard/services/source_code_reader.rb,
lib/rails_error_dashboard/value_objects/error_context.rb,
app/jobs/rails_error_dashboard/async_error_logging_job.rb,
app/jobs/rails_error_dashboard/reopen_linked_issue_job.rb,
lib/rails_error_dashboard/commands/batch_delete_errors.rb,
lib/rails_error_dashboard/commands/batch_unmute_errors.rb,
lib/rails_error_dashboard/commands/link_existing_issue.rb,
lib/rails_error_dashboard/commands/update_error_status.rb,
lib/rails_error_dashboard/queries/action_cable_summary.rb,
lib/rails_error_dashboard/queries/cache_health_summary.rb,
lib/rails_error_dashboard/queries/deprecation_warnings.rb,
lib/rails_error_dashboard/services/backtrace_processor.rb,
lib/rails_error_dashboard/services/baseline_calculator.rb,
lib/rails_error_dashboard/services/github_issue_client.rb,
lib/rails_error_dashboard/services/gitlab_issue_client.rb,
lib/rails_error_dashboard/services/n_plus_one_detector.rb,
lib/rails_error_dashboard/services/pearson_correlation.rb,
lib/rails_error_dashboard/services/severity_classifier.rb,
lib/rails_error_dashboard/services/variable_serializer.rb,
app/controllers/rails_error_dashboard/errors_controller.rb,
lib/rails_error_dashboard/commands/batch_resolve_errors.rb,
lib/rails_error_dashboard/services/breadcrumb_collector.rb,
lib/rails_error_dashboard/services/environment_snapshot.rb,
lib/rails_error_dashboard/services/error_hash_generator.rb,
lib/rails_error_dashboard/services/issue_body_formatter.rb,
lib/rails_error_dashboard/services/issue_tracker_client.rb,
lib/rails_error_dashboard/services/notification_helpers.rb,
lib/rails_error_dashboard/commands/update_error_priority.rb,
lib/rails_error_dashboard/queries/active_storage_summary.rb,
lib/rails_error_dashboard/services/cause_chain_extractor.rb,
lib/rails_error_dashboard/services/codeberg_issue_client.rb,
lib/rails_error_dashboard/services/github_link_generator.rb,
lib/rails_error_dashboard/services/sensitive_data_filter.rb,
lib/rails_error_dashboard/services/similarity_calculator.rb,
lib/rails_error_dashboard/services/slack_payload_builder.rb,
app/controllers/rails_error_dashboard/webhooks_controller.rb,
lib/rails_error_dashboard/commands/upsert_cascade_pattern.rb,
lib/rails_error_dashboard/plugins/jira_integration_plugin.rb,
lib/rails_error_dashboard/queries/database_health_summary.rb,
lib/rails_error_dashboard/services/notification_throttler.rb,
lib/rails_error_dashboard/services/statistical_classifier.rb,
lib/rails_error_dashboard/services/system_health_snapshot.rb,
lib/rails_error_dashboard/commands/find_or_increment_error.rb,
lib/rails_error_dashboard/services/analytics_cache_manager.rb,
lib/rails_error_dashboard/services/discord_payload_builder.rb,
lib/rails_error_dashboard/services/local_variable_capturer.rb,
lib/rails_error_dashboard/services/webhook_payload_builder.rb,
app/jobs/rails_error_dashboard/email_error_notification_job.rb,
app/jobs/rails_error_dashboard/slack_error_notification_job.rb,
app/mailers/rails_error_dashboard/error_notification_mailer.rb,
lib/rails_error_dashboard/services/baseline_alert_throttler.rb,
lib/rails_error_dashboard/services/markdown_error_formatter.rb,
lib/rails_error_dashboard/subscribers/breadcrumb_subscriber.rb,
app/controllers/rails_error_dashboard/application_controller.rb,
app/jobs/rails_error_dashboard/swallowed_exception_flush_job.rb,
lib/rails_error_dashboard/services/database_health_inspector.rb,
lib/rails_error_dashboard/services/diagnostic_dump_generator.rb,
lib/rails_error_dashboard/services/pagerduty_payload_builder.rb,
lib/rails_error_dashboard/services/priority_score_calculator.rb,
lib/rails_error_dashboard/subscribers/rack_attack_subscriber.rb,
app/jobs/rails_error_dashboard/discord_error_notification_job.rb,
app/jobs/rails_error_dashboard/webhook_error_notification_job.rb,
lib/rails_error_dashboard/commands/find_or_create_application.rb,
lib/rails_error_dashboard/commands/flush_swallowed_exceptions.rb,
lib/rails_error_dashboard/queries/swallowed_exception_summary.rb,
lib/rails_error_dashboard/subscribers/action_cable_subscriber.rb,
lib/generators/rails_error_dashboard/install/install_generator.rb,
lib/rails_error_dashboard/commands/increment_cascade_detection.rb,
lib/rails_error_dashboard/services/swallowed_exception_tracker.rb,
lib/rails_error_dashboard/subscribers/issue_tracker_subscriber.rb,
app/jobs/rails_error_dashboard/add_issue_recurrence_comment_job.rb,
app/jobs/rails_error_dashboard/pagerduty_error_notification_job.rb,
lib/rails_error_dashboard/subscribers/active_storage_subscriber.rb,
lib/rails_error_dashboard/commands/calculate_cascade_probability.rb,
lib/rails_error_dashboard/services/error_notification_dispatcher.rb,
lib/rails_error_dashboard/services/baseline_alert_payload_builder.rb,
lib/generators/rails_error_dashboard/uninstall/uninstall_generator.rb,
lib/generators/rails_error_dashboard/solid_queue/solid_queue_generator.rb

Overview

Rack Middleware: Final safety net for uncaught errors This catches errors that somehow escape controller error handling Positioned at the Rack layer (outermost layer of Rails)

Middleware stack order (outer to inner):

  1. ErrorCatcher (this file) ← Catches everything

  2. ActionDispatch middleware

  3. Rails routing

  4. Controllers (with ErrorHandler concern)

This ensures NO error goes unreported

Defined Under Namespace

Modules: ApplicationHelper, BacktraceHelper, Commands, Generators, Helpers, Logger, Middleware, OverviewHelper, Plugins, Queries, Services, Subscribers, UserAgentHelper, ValueObjects Classes: AddIssueRecurrenceCommentJob, Application, ApplicationController, ApplicationJob, ApplicationMailer, AsyncErrorLoggingJob, BaselineAlertJob, CascadePattern, CloseLinkedIssueJob, Configuration, ConfigurationError, CreateIssueJob, DiagnosticDump, DigestMailer, DiscordErrorNotificationJob, EmailErrorNotificationJob, Engine, ErrorBaseline, ErrorComment, ErrorLog, ErrorLogsRecord, ErrorNotificationMailer, ErrorOccurrence, ErrorReporter, ErrorsController, ManualErrorReporter, PagerdutyErrorNotificationJob, Plugin, PluginRegistry, ReopenLinkedIssueJob, RetentionCleanupJob, ScheduledDigestJob, SlackErrorNotificationJob, SwallowedException, SwallowedExceptionFlushJob, WebhookErrorNotificationJob, WebhooksController

Constant Summary collapse

VERSION =
"0.5.12"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Get or initialize configuration



139
140
141
# File 'lib/rails_error_dashboard.rb', line 139

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.add_breadcrumb(message, metadata = nil) ⇒ Object

Add a custom breadcrumb to the current request’s trail No-ops if breadcrumbs are disabled or no buffer is initialized.

Examples:

RailsErrorDashboard.add_breadcrumb("checkout started", { cart_id: 123 })

Parameters:

  • message (String)

    Human-readable description

  • metadata (Hash, nil) (defaults to: nil)

    Optional key-value pairs



209
210
211
212
# File 'lib/rails_error_dashboard.rb', line 209

def self.add_breadcrumb(message,  = nil)
  return unless configuration.enable_breadcrumbs
  Services::BreadcrumbCollector.add("custom", message, metadata: )
end

.configure {|configuration| ... } ⇒ Object

Configure the gem

Yields:



144
145
146
# File 'lib/rails_error_dashboard.rb', line 144

def configure
  yield(configuration)
end

.on_critical_error(&block) ⇒ Object

Register a callback for when a critical error is logged

Examples:

RailsErrorDashboard.on_critical_error do |error_log|
  PagerDuty.trigger(error_log)
end

Parameters:

  • block (Proc)

    The callback to execute, receives error_log as parameter



189
190
191
# File 'lib/rails_error_dashboard.rb', line 189

def self.on_critical_error(&block)
  configuration.notification_callbacks[:critical_error] << block if block_given?
end

.on_error_logged(&block) ⇒ Object

Register a callback for when any error is logged

Examples:

RailsErrorDashboard.on_error_logged do |error_log|
  puts "Error logged: #{error_log.error_type}"
end

Parameters:

  • block (Proc)

    The callback to execute, receives error_log as parameter



179
180
181
# File 'lib/rails_error_dashboard.rb', line 179

def self.on_error_logged(&block)
  configuration.notification_callbacks[:error_logged] << block if block_given?
end

.on_error_resolved(&block) ⇒ Object

Register a callback for when an error is resolved

Examples:

RailsErrorDashboard.on_error_resolved do |error_log|
  Slack.notify("Error #{error_log.id} resolved")
end

Parameters:

  • block (Proc)

    The callback to execute, receives error_log as parameter



199
200
201
# File 'lib/rails_error_dashboard.rb', line 199

def self.on_error_resolved(&block)
  configuration.notification_callbacks[:error_resolved] << block if block_given?
end

.pluginsArray<Plugin>

Get all registered plugins

Returns:

  • (Array<Plugin>)

    List of registered plugins



169
170
171
# File 'lib/rails_error_dashboard.rb', line 169

def self.plugins
  PluginRegistry.plugins
end

.register_plugin(plugin) ⇒ Boolean

Register a plugin

Parameters:

  • plugin (Plugin)

    The plugin instance to register

Returns:

  • (Boolean)

    True if registered successfully, false otherwise



157
158
159
# File 'lib/rails_error_dashboard.rb', line 157

def self.register_plugin(plugin)
  PluginRegistry.register(plugin)
end

.reset_configuration!Object

Reset configuration to defaults



149
150
151
# File 'lib/rails_error_dashboard.rb', line 149

def reset_configuration!
  @configuration = Configuration.new
end

.unregister_plugin(plugin_name) ⇒ Object

Unregister a plugin by name

Parameters:

  • plugin_name (String)

    The name of the plugin to unregister



163
164
165
# File 'lib/rails_error_dashboard.rb', line 163

def self.unregister_plugin(plugin_name)
  PluginRegistry.unregister(plugin_name)
end