mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -06:00
DEV: Allow raw PG tracing to be enabled only for sidekiq processes
This commit is contained in:
parent
42729e6a27
commit
cd3fab9ccc
@ -4,6 +4,9 @@
|
||||
# to be streamed to files for debugging. The filenames are formatted
|
||||
# like tmp/pgtrace/{{PID}}_{{CONNECTION_OBJECT_ID}}.txt
|
||||
#
|
||||
# Setting TRACE_PG_CONNECTIONS=SIDEKIQ will only trace connections
|
||||
# on in sidekiq (safer, because there will be minimal user-facing perf impact)
|
||||
#
|
||||
# Files will be automatically deleted when the connection is closed gracefully
|
||||
# (e.g. when activerecord closes it after a period of inactivity)
|
||||
# Files will not be automatically deleted when closed abruptly
|
||||
@ -17,6 +20,7 @@ if ENV["TRACE_PG_CONNECTIONS"]
|
||||
|
||||
def initialize(*args)
|
||||
super(*args).tap do
|
||||
next if ENV["TRACE_PG_CONNECTIONS"] == "SIDEKIQ" && !Sidekiq.server?
|
||||
FileUtils.mkdir_p(TRACE_DIR)
|
||||
@trace_filename = "#{TRACE_DIR}/#{Process.pid}_#{self.object_id}.txt"
|
||||
trace File.new(@trace_filename, "w")
|
||||
@ -25,6 +29,7 @@ if ENV["TRACE_PG_CONNECTIONS"]
|
||||
|
||||
def close
|
||||
super.tap do
|
||||
next if ENV["TRACE_PG_CONNECTIONS"] == "SIDEKIQ" && !Sidekiq.server?
|
||||
File.delete(@trace_filename)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user