Class: ScoutApm::Instruments::Process::ProcessMemory
- Inherits:
-
Object
- Object
- ScoutApm::Instruments::Process::ProcessMemory
- Defined in:
- lib/scout_apm/instruments/process/process_memory.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #human_name ⇒ Object
-
#initialize(logger) ⇒ ProcessMemory
constructor
A new instance of ProcessMemory.
- #metric_name ⇒ Object
- #metric_type ⇒ Object
- #metrics(_time) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(logger) ⇒ ProcessMemory
Returns a new instance of ProcessMemory.
7 8 9 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 7 def initialize(logger) @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 5 def logger @logger end |
Instance Method Details
#human_name ⇒ Object
19 20 21 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 19 def human_name "Process Memory" end |
#metric_name ⇒ Object
15 16 17 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 15 def metric_name "Physical" end |
#metric_type ⇒ Object
11 12 13 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 11 def metric_type "Memory" end |
#metrics(_time) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 23 def metrics(_time) result = run if result = MetricMeta.new("#{metric_type}/#{metric_name}") stat = MetricStats.new(false) stat.update!(result) { => stat } else {} end end |
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/scout_apm/instruments/process/process_memory.rb', line 35 def run case RUBY_PLATFORM.downcase when /linux/ get_mem_from_procfile when /darwin9/ # 10.5 get_mem_from_shell("ps -o rsz") when /darwin1[01234]/ # 10.6 - 10.11 get_mem_from_shell("ps -o rss") else 0 # What default? was nil. end.tap { |res| logger.debug "#{human_name}: #{res.inspect}" } end |