mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 16:25:17 +08:00
DEV: Log number of live slots used by requests (#29884)
This commit is contained in:
parent
5b19e2ca0f
commit
5abee8ac6b
|
@ -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] * 1000
|
||||
output[:db_calls] = sql[:calls]
|
||||
end
|
||||
|
||||
redis = data[:redis]
|
||||
|
||||
if redis
|
||||
if redis = data[:redis]
|
||||
output[:redis] = redis[:duration] * 1000
|
||||
output[:redis_calls] = redis[:calls]
|
||||
end
|
||||
|
||||
net = data[:net]
|
||||
|
||||
if net
|
||||
if net = data[:net]
|
||||
output[:net] = net[:duration] * 1000
|
||||
output[: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]
|
||||
end
|
||||
end
|
||||
|
||||
output
|
||||
|
|
|
@ -90,7 +90,10 @@ class MethodProfiler
|
|||
|
||||
def 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],
|
||||
}
|
||||
end
|
||||
|
||||
def self.clear
|
||||
|
|
Loading…
Reference in New Issue
Block a user