Class: Instana::Collector::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/instana/collectors/memory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemory

Returns a new instance of Memory.



8
9
10
11
12
# File 'lib/instana/collectors/memory.rb', line 8

def initialize
  @payload_key = :memory
  @last_report = {}
  @this_mem = {}
end

Instance Attribute Details

#payload_keyObject

Returns the value of attribute payload_key.



6
7
8
# File 'lib/instana/collectors/memory.rb', line 6

def payload_key
  @payload_key
end

Instance Method Details

#collectObject

collect

To collect process memory usage.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/instana/collectors/memory.rb', line 19

def collect
  @this_mem.clear
  @this_mem[:rss_size] = ::GetProcessMem.new(Process.pid).kb

  @this_mem = ::Instana::Util.enforce_deltas(@this_mem, @last_report)
  unless @this_mem.empty?
    @last_report.merge!(@this_mem)
    @this_mem
  else
    nil
  end
rescue => e
  ::Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
  ::Instana.logger.debug e.backtrace.join("\r\n")
end