From dc50d8892699bf17b2399865ead8b27ce45b60ed Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Thu, 4 Aug 2022 12:34:53 +0200 Subject: [PATCH] Rename gc_total_time to gc_time (#874) 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 --- .changesets/rename-gc_total_time-metric-to-gc_time.md | 6 ++++++ lib/appsignal/probes/mri.rb | 4 ++-- spec/lib/appsignal/probes/mri_spec.rb | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changesets/rename-gc_total_time-metric-to-gc_time.md diff --git a/.changesets/rename-gc_total_time-metric-to-gc_time.md b/.changesets/rename-gc_total_time-metric-to-gc_time.md new file mode 100644 index 000000000..7999ec0a2 --- /dev/null +++ b/.changesets/rename-gc_total_time-metric-to-gc_time.md @@ -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. diff --git a/lib/appsignal/probes/mri.rb b/lib/appsignal/probes/mri.rb index 502f73818..b7a86502c 100644 --- a/lib/appsignal/probes/mri.rb +++ b/lib/appsignal/probes/mri.rb @@ -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 diff --git a/spec/lib/appsignal/probes/mri_spec.rb b/spec/lib/appsignal/probes/mri_spec.rb index fe853c6a1..5e2789fd6 100644 --- a/spec/lib/appsignal/probes/mri_spec.rb +++ b/spec/lib/appsignal/probes/mri_spec.rb @@ -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 @@ -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