mirror of
https://github.com/discourse/discourse.git
synced 2025-04-17 18:49:02 +08:00
DEV: Log number of live slots used by requests
This commit is contained in:
parent
667a09b159
commit
4dda44e2a9
@ -109,26 +109,28 @@ 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 start_heap_live_slots = data[:__start_heap_live_slots]
|
||||
if heap_live_slots = GC.stat[:heap_live_slots] - start_heap_live_slots
|
||||
output[:heap_live_slots] = heap_live_slots if heap_live_slots > 0
|
||||
end
|
||||
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_heap_live_slots: GC.stat[:heap_live_slots],
|
||||
}
|
||||
end
|
||||
|
||||
def self.clear
|
||||
|
Loading…
x
Reference in New Issue
Block a user