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:
parent
80b93e06f7
commit
c76ca876a6
|
@ -122,13 +122,19 @@ class UserAuthToken < ActiveRecord::Base
|
|||
expire_before = SiteSetting.maximum_session_age.hours.ago
|
||||
|
||||
user_token =
|
||||
find_by(
|
||||
where(
|
||||
"(auth_token = :token OR
|
||||
prev_auth_token = :token) AND rotated_at > :expire_before",
|
||||
token: token,
|
||||
expire_before: expire_before,
|
||||
)
|
||||
|
||||
if SiteSetting.verbose_auth_token_logging && path = opts.dig(:path)
|
||||
user_token = user_token.annotate("path:#{path}")
|
||||
end
|
||||
|
||||
user_token = user_token.first
|
||||
|
||||
if !user_token
|
||||
log_verbose(
|
||||
action: "miss token",
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue