From b907f7d307c1c662fc0ea3f93df75840beebfb81 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Sat, 25 Nov 2017 08:10:49 +0800 Subject: [PATCH] Add more metrics to lograge's output if `MethodProfiler` is enabled. --- config/initializers/100-lograge.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/initializers/100-lograge.rb b/config/initializers/100-lograge.rb index 7a7cb526898..f624361f9ac 100644 --- a/config/initializers/100-lograge.rb +++ b/config/initializers/100-lograge.rb @@ -19,6 +19,15 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV[" database: RailsMultisite::ConnectionManagement.current_db, } + if data = Thread.current[:_method_profiler] + sql = data[:sql] + output[:db] = sql[:duration] * 1000 + output[:db_calls] = sql[:calls] + redis = data[:redis] + output[:redis] = redis[:duration] * 1000 + output[:redis_calls] = redis[:calls] + end + output end