Class: RailsErrorDashboard::Services::DatabaseHealthInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_error_dashboard/services/database_health_inspector.rb

Overview

Display-time only service: queries PostgreSQL system tables when the DB Health page loads. NOT used in the capture path.

Feature-detects PostgreSQL — returns nil for tables/indexes/activity on SQLite/MySQL. Connection pool stats work on all adapters. Every method individually rescue-wrapped (returns nil).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



12
13
14
15
16
17
18
# File 'lib/rails_error_dashboard/services/database_health_inspector.rb', line 12

def self.call
  new.call
rescue => e
  Rails.logger.error("[RailsErrorDashboard] DatabaseHealthInspector failed: #{e.class}: #{e.message}")
  { adapter: nil, postgresql: false, connection_pool: nil, tables: nil,
    indexes: nil, unused_indexes: nil, activity: nil }
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_error_dashboard/services/database_health_inspector.rb', line 20

def call
  {
    adapter: adapter_name,
    postgresql: postgresql?,
    connection_pool: connection_pool_stats,
    tables: postgresql? ? table_stats : nil,
    indexes: postgresql? ? index_stats : nil,
    unused_indexes: postgresql? ? unused_index_stats : nil,
    activity: postgresql? ? activity_stats : nil
  }
end