2019-08-28 14:52:16 +02:00
|
|
|
module OpenProject
|
|
|
|
|
module Logging
|
2022-10-20 10:58:59 +02:00
|
|
|
module ThreadPoolContextBuilder
|
|
|
|
|
module_function
|
|
|
|
|
|
2019-08-28 14:52:16 +02:00
|
|
|
##
|
|
|
|
|
# Build an object informing about current Rails connection pool
|
|
|
|
|
# and active thread usage and their traces
|
2022-10-20 10:58:59 +02:00
|
|
|
def build!
|
2019-08-28 14:52:16 +02:00
|
|
|
thread_info = {}
|
|
|
|
|
Thread.list.each_with_index do |t, i|
|
|
|
|
|
thread_info[i] = {
|
|
|
|
|
info: t.inspect,
|
|
|
|
|
trace: t.backtrace.take(2)
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
connection_pool: ActiveRecord::Base.connection_pool.stat,
|
|
|
|
|
thread_info:
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|