Class: Dbwatcher::Services::SystemInfo::RuntimeInfoCollector

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

Overview

Runtime information collector service

Collects runtime-specific information including Ruby version, Rails version, loaded gems, environment variables, and application configuration.

This class is necessarily complex due to the comprehensive runtime information it needs to collect across different Ruby and Rails environments. rubocop:disable Metrics/ClassLength

Examples:

info = SystemInfo::RuntimeInfoCollector.call
puts info[:ruby_version]
puts info[:rails_version]
puts info[:gem_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)

    runtime information



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

def self.call
  new.call
end

Instance Method Details

#callHash

Collect runtime information

rubocop:disable Metrics/MethodLength

Returns:

  • (Hash)

    collected runtime information



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/dbwatcher/services/system_info/runtime_info_collector.rb', line 36

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

  {
    ruby_version: collect_ruby_version,
    ruby_engine: collect_ruby_engine,
    ruby_patchlevel: collect_ruby_patchlevel,
    rails_version: collect_rails_version,
    rails_env: collect_rails_env,
    environment: collect_environment,
    pid: Process.pid,
    gem_count: collect_gem_count,
    loaded_gems: collect_loaded_gems,
    load_path: collect_load_path_info,
    environment_variables: collect_environment_variables,
    application_config: collect_application_config
  }
rescue StandardError => e
  log_error "Runtime info collection failed: #{e.message}"
  { error: e.message }
end