Class: RailsPerformance::SystemMonitor::MemoryUsage

Inherits:
ResourceChart
  • Object
show all
Defined in:
lib/rails_performance/system_monitor/resource_chart.rb

Instance Attribute Summary

Attributes inherited from ResourceChart

#description, #key, #legend, #server, #subtitle, #type

Instance Method Summary collapse

Methods inherited from ResourceChart

#data, #id, #signal

Constructor Details

#initialize(server) ⇒ MemoryUsage

Returns a new instance of MemoryUsage.



52
53
54
55
56
57
58
59
60
61
# File 'lib/rails_performance/system_monitor/resource_chart.rb', line 52

def initialize server
  super(
    server:,
    key: :memory,
    type: "Usage",
    subtitle: "Memory",
    description: "App memory usage",
    legend: "Usage",
  )
end

Instance Method Details

#format(measurement) ⇒ Object



63
64
65
# File 'lib/rails_performance/system_monitor/resource_chart.rb', line 63

def format measurement
  measurement.to_f.round(2)
end

#measureObject



67
68
69
70
71
72
# File 'lib/rails_performance/system_monitor/resource_chart.rb', line 67

def measure
  GetProcessMem.new.bytes
rescue => e
  ::Rails.logger.error "Error fetching memory usage: #{e.message}"
  0
end