mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 23:21:11 +08:00
DEV: Track SQL queries from MiniSql (#28824)
`track_sql_queries` only returned queries that were executed by ActiveRecord. All queries executed through DB.exec, DB.query and others were not returned.
This commit is contained in:
@ -99,6 +99,16 @@ class MiniSqlMultisiteConnection < MiniSql::ActiveRecordPostgres::Connection
|
||||
CustomBuilder.new(self, sql)
|
||||
end
|
||||
|
||||
def run(sql, params)
|
||||
ActiveSupport::Notifications.instrument(
|
||||
"sql.mini_sql",
|
||||
sql: sql_fragment(sql, *params),
|
||||
name: "MiniSql",
|
||||
)
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def sql_fragment(query, *args)
|
||||
if args.length > 0
|
||||
param_encoder.encode(query, *args)
|
||||
|
Reference in New Issue
Block a user