Skip to content

Commit

Permalink
Use base unit, bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
robertomiranda committed Sep 20, 2024
1 parent 8b52bcc commit 29e9f58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/promenade/pitchfork/mem_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
module Promenade
module Pitchfork
class MemStats
Promenade.gauge :pitchfork_memory_usage_kilobytes do
doc "Memory usage in kilobytes, broken down by type (RSS, PSS, SHARED_MEMORY)"
Promenade.gauge :pitchfork_memory_usage_bytes do
doc "Memory usage in bytes, broken down by type (RSS, PSS, SHARED_MEMORY)"
end


Expand All @@ -19,9 +19,9 @@ def initialize
end

def instrument
Promenade.metric(:pitchfork_memory_usage_kilobytes).set({ type: "Rss" }, @mem_info.rss)
Promenade.metric(:pitchfork_memory_usage_kilobytes).set({ type: "Pss" }, @mem_info.pss)
Promenade.metric(:pitchfork_memory_usage_kilobytes).set({ type: "Shared" }, @mem_info.shared_memory)
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

def self.instrument
Expand Down
8 changes: 4 additions & 4 deletions spec/promenade/pitchfork/mem_stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
it "sets the metrics correctly" do
stats = Promenade::Pitchfork::MemStats.new

expect(Promenade).to receive(:metric).with(:pitchfork_memory_usage_kilobytes).and_return(metric)
expect(Promenade).to receive(:metric).with(:pitchfork_memory_usage_bytes).and_return(metric)

expect(metric).to receive(:set).with({:type=>"Rss"}, 100)
expect(metric).to receive(:set).with({:type=>"Pss"}, 50)
expect(metric).to receive(:set).with({:type=>"Shared"}, 50)
expect(metric).to receive(:set).with({:type=>"RSS"}, 102400)
expect(metric).to receive(:set).with({:type=>"PSS"}, 51200)
expect(metric).to receive(:set).with({:type=>"Shared"}, 51200)

stats.instrument
end
Expand Down

0 comments on commit 29e9f58

Please sign in to comment.