Class: Promenade::Pitchfork::MemStats

Inherits:
Object
  • Object
show all
Defined in:
lib/promenade/pitchfork/mem_stats.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemStats

Returns a new instance of MemStats.



14
15
16
17
18
# File 'lib/promenade/pitchfork/mem_stats.rb', line 14

def initialize
  return unless defined?(::Pitchfork) && defined?(::Pitchfork::MemInfo)

  @mem_info = ::Pitchfork::MemInfo.new(Process.pid)
end

Class Method Details

.instrumentObject



26
27
28
29
# File 'lib/promenade/pitchfork/mem_stats.rb', line 26

def self.instrument
  new.instrument
rescue StandardError
end

Instance Method Details

#instrumentObject



20
21
22
23
24
# File 'lib/promenade/pitchfork/mem_stats.rb', line 20

def instrument
  Promenade.metric(:pitchfork_memory_usage_bytes).set({ type: "RSS" }, @mem_info.rss * 1024)
  Promenade.metric(:pitchfork_memory_usage_bytes).set({ type: "PSS" }, @mem_info.pss * 1024)
  Promenade.metric(:pitchfork_memory_usage_bytes).set({ type: "Shared" }, @mem_info.shared_memory * 1024)
end