A platform for community discussion. Free, open, simple.
DEV: Log number of live slots used by requests (#29884)
Bianca Nenciu5abee8ac6be9
diff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rbindex 3fc133d139f..22ed71b13db 100644--- a/config/initializers/101-lograge.rb+++ b/config/initializers/101-lograge.rb@@ -109,26 +109,27 @@ if ENV["ENABLE_LOGSTASH_LOGGER"] == "1"}if data = (Thread.current[:_method_profiler] || event.payload[:timings])- sql = data[:sql]-- if sql+ if sql = data[:sql]output[:db] = sql[:duration] * 1000output[:db_calls] = sql[:calls]end- redis = data[:redis]-- if redis+ if redis = data[:redis]output[:redis] = redis[:duration] * 1000output[:redis_calls] = redis[:calls]end- net = data[:net]-- if net+ if net = data[:net]output[:net] = net[:duration] * 1000output[:net_calls] = net[:calls]end++ # MethodProfiler.stop is called after this lambda, so the delta+ # must be computed here.+ if data[:__start_gc_heap_live_slots]+ output[:heap_live_slots] = GC.stat[:heap_live_slots] -+ data[:__start_gc_heap_live_slots]+ endendoutputdiff --git a/lib/method_profiler.rb b/lib/method_profiler.rbindex ac95db890a5..eb639a75805 100644--- a/lib/method_profiler.rb+++ b/lib/method_profiler.rb@@ -90,7 +90,10 @@ class MethodProfilerdef self.start(transfer = nil)Thread.current[:_method_profiler] = transfer ||- { __start: Process.clock_gettime(Process::CLOCK_MONOTONIC) }+ {+ __start: Process.clock_gettime(Process::CLOCK_MONOTONIC),+ __start_gc_heap_live_slots: GC.stat[:heap_live_slots],+ }enddef self.clear