Class: ScoutApm::Instruments::Process::ProcessMemory
- Inherits:
-
Object
- Object
- ScoutApm::Instruments::Process::ProcessMemory
- Defined in:
- lib/scout_apm/instruments/process/process_memory.rb
Instance Method Summary collapse
- #human_name ⇒ Object
-
#initialize(context) ⇒ ProcessMemory
constructor
A new instance of ProcessMemory.
- #logger ⇒ Object
- #metric_name ⇒ Object
- #metric_type ⇒ Object
- #metrics(timestamp, store) ⇒ Object
- #rss ⇒ Object
- #rss_in_mb ⇒ Object
-
#rss_to_mb(rss) ⇒ Object
Account for Darwin returning maxrss in bytes and Linux in KB.
- #run ⇒ Object
Constructor Details
#initialize(context) ⇒ ProcessMemory
Returns a new instance of ProcessMemory.
21 22 23 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 21 def initialize(context) @context = context end |
Instance Method Details
#human_name ⇒ Object
33 34 35 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 33 def human_name "Process Memory" end |
#logger ⇒ Object
53 54 55 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 53 def logger @context.logger end |
#metric_name ⇒ Object
29 30 31 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 29 def metric_name "Physical" end |
#metric_type ⇒ Object
25 26 27 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 25 def metric_type "Memory" end |
#metrics(timestamp, store) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 37 def metrics(, store) result = run if result = MetricMeta.new("#{metric_type}/#{metric_name}") stat = MetricStats.new(false) stat.update!(result) store.track!({ => stat }, :timestamp => ) else {} end end |
#rss ⇒ Object
13 14 15 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 13 def rss ::Process.rusage.maxrss end |
#rss_in_mb ⇒ Object
17 18 19 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 17 def rss_in_mb rss_to_mb(rss) end |
#rss_to_mb(rss) ⇒ Object
Account for Darwin returning maxrss in bytes and Linux in KB. Used by the slow converters. Doesn’t feel like this should go here though…more of a utility.
8 9 10 11 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 8 def rss_to_mb(rss) kilobyte_adjust = @context.environment.os == 'darwin' ? 1024 : 1 rss.to_f / 1024 / kilobyte_adjust end |
#run ⇒ Object
49 50 51 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 49 def run rss_in_mb.tap { |res| logger.debug "#{human_name}: #{res.inspect}" } end |