Class: Dbwatcher::Services::SystemInfo::DatabaseInfoCollector

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/dbwatcher/services/system_info/database_info_collector.rb

Overview

Database information collector service

Collects database-specific information including adapter, version, connection pool stats, table counts, and schema information.

This class is necessarily complex due to the comprehensive database information it needs to collect across different database systems. rubocop:disable Metrics/ClassLength

Examples:

info = SystemInfo::DatabaseInfoCollector.call
puts info[:adapter]
puts info[:version]
puts info[:tables].count

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug_enabled?, #log_debug, #log_error, #log_info, #log_warn

Class Method Details

.callHash

Class method to create instance and call

Returns:

  • (Hash)

    database information



28
29
30
# File 'lib/dbwatcher/services/system_info/database_info_collector.rb', line 28

def self.call
  new.call
end

Instance Method Details

#callObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dbwatcher/services/system_info/database_info_collector.rb', line 32

def call
  log_info "#{self.class.name}: Collecting database information"

  {
    adapter: collect_adapter_info,
    version: collect_database_version,
    connection_pool: collect_connection_pool_info,
    tables: collect_table_info,
    schema: collect_schema_info,
    indexes: collect_index_info,
    query_stats: collect_query_stats
  }
rescue StandardError => e
  log_error "Database info collection failed: #{e.message}"
  { error: e.message }
end