DEV: Add more debugging information to AR query logs on GitHub actions (#25237)

Why this change?

We have been chasing a problem with our flaky system test where the user
is logged out when it should never be.

What does this change do?

1. Logs the request path when lookup a user auth token.
2. Logs the request path and also the current thread's object id in
   ActiveRecord query logs.
This commit is contained in:
Alan Guo Xiang Tan
2024-01-12 13:06:29 +08:00
committed by GitHub
parent 80b93e06f7
commit c76ca876a6
2 changed files with 17 additions and 1 deletions

View File

@ -53,6 +53,16 @@ Discourse::Application.configure do
config.active_record.verbose_query_logs = true
config.active_record.query_log_tags_enabled = true
config.active_record.query_log_tags = [
:application,
:controller,
:action,
{
request_path: ->(context) { context[:controller]&.request&.path },
thread_id: ->(context) { Thread.current.object_id },
},
]
config.after_initialize do
ActiveRecord::LogSubscriber.backtrace_cleaner.add_silencer do |line|
line =~ %r{lib/freedom_patches}