mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Optional detailed performance logging for Sidekiq jobs (#7091)
By default, this does nothing. Two environment variables are available: - `DISCOURSE_LOG_SIDEKIQ` Set to `"1"` to enable logging. This will log all completed jobs to `log/rails/sidekiq.log`, along with various db/redis/network statistics. This is useful to track down poorly performing jobs. - `DISCOURSE_LOG_SIDEKIQ_INTERVAL` (seconds) Check running jobs periodically, and log their current duration. They will appear in the logs with `status:pending`. This is useful to track down jobs which take a long time, then crash sidekiq before completing.
This commit is contained in:
@@ -15,26 +15,7 @@ class Middleware::RequestTracker
|
||||
# # do stuff with env and data
|
||||
# end
|
||||
def self.register_detailed_request_logger(callback)
|
||||
|
||||
unless @patched_instrumentation
|
||||
MethodProfiler.patch(PG::Connection, [
|
||||
:exec, :async_exec, :exec_prepared, :send_query_prepared, :query, :exec_params
|
||||
], :sql)
|
||||
|
||||
MethodProfiler.patch(Redis::Client, [
|
||||
:call, :call_pipeline
|
||||
], :redis)
|
||||
|
||||
MethodProfiler.patch(Net::HTTP, [
|
||||
:request
|
||||
], :net, no_recurse: true)
|
||||
|
||||
MethodProfiler.patch(Excon::Connection, [
|
||||
:request
|
||||
], :net)
|
||||
@patched_instrumentation = true
|
||||
end
|
||||
|
||||
MethodProfiler.ensure_discourse_instrumentation!
|
||||
(@@detailed_request_loggers ||= []) << callback
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user