Skip to content

Commit

Permalink
Rename gc_total_time to gc_time (#874)
Browse files Browse the repository at this point in the history
Update naming to only be about the time measured.

It no longer reports the total time, but reports the delta of two
measurements.

Part of #868
  • Loading branch information
tombruijn committed Aug 4, 2022
1 parent 7cfed98 commit dc50d88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changesets/rename-gc_total_time-metric-to-gc_time.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "change"
---

Rename the (so far privately reported) `gc_total_time` metric to `gc_time`. It no longer reports the total time of Garbage Collection measured, but only the time between two (minutely) measurements.
4 changes: 2 additions & 2 deletions lib/appsignal/probes/mri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def call
)

set_gauge("thread_count", Thread.list.size)
gauge_delta(:gc_total_time, @gc_profiler.total_time) do |total_time|
set_gauge("gc_total_time", total_time) if total_time > 0
gauge_delta(:gc_time, @gc_profiler.total_time) do |gc_time|
set_gauge("gc_time", gc_time) if gc_time > 0
end

gc_stats = GC.stat
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/appsignal/probes/mri_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def set_gauge(*args) # rubocop:disable Naming/AccessorMethodName
expect_gauge_value("thread_count")
end

it "tracks GC total time" do
it "tracks GC time between measurements" do
expect(gc_profiler_mock).to receive(:total_time).and_return(10, 15)
probe.call
probe.call
expect_gauge_value("gc_total_time", 5)
expect_gauge_value("gc_time", 5)
end

context "when GC total time overflows" do
Expand All @@ -66,7 +66,7 @@ def set_gauge(*args) # rubocop:disable Naming/AccessorMethodName
probe.call # Report delta value based on cached value
probe.call # The value overflows and reports no value. Then stores 0 in the cache
probe.call # Report new value based on cache of 0
expect_gauges([["gc_total_time", 5], ["gc_total_time", 10]])
expect_gauges([["gc_time", 5], ["gc_time", 10]])
end
end

Expand Down

0 comments on commit dc50d88

Please sign in to comment.