2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-04 08:47:37 +08:00

FEATURE: add instrumentation for all external net calls

This commit is contained in:
Sam 2018-02-21 15:19:59 +11:00
parent 5c40ae9e63
commit ca1a3f37e3
3 changed files with 53 additions and 1 deletions

View file

@ -8,6 +8,13 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
Rails.application.configure do
config.lograge.enabled = true
Lograge.ignore(lambda do |event|
# this is our hijack magic status,
# no point logging this cause we log again
# direct from hijack
event.payload[:status] == 418
end)
config.lograge.custom_payload do |controller|
begin
username =
@ -46,7 +53,7 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
database: RailsMultisite::ConnectionManagement.current_db,
}
if data = Thread.current[:_method_profiler]
if data = (Thread.current[:_method_profiler] || event.payload[:timings])
sql = data[:sql]
if sql
@ -60,6 +67,13 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["
output[:redis] = redis[:duration] * 1000
output[:redis_calls] = redis[:calls]
end
net = data[:net]
if net
output[:net] = net[:duration] * 1000
output[:net_calls] = net[:calls]
end
end
output