6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/active_record/sql_analyzer/monkeypatches/query.rb', line 6
def execute(sql, *args)
return super unless SqlAnalyzer.config
safe_sql = nil
SqlAnalyzer.config[:analyzers].each do |analyzer|
if SqlAnalyzer.config[:should_log_sample_proc].call(analyzer[:name])
safe_sql ||= sql.encode(Encoding::UTF_8, invalid: :replace, undef: :replace)
if safe_sql =~ analyzer[:table_regex]
SqlAnalyzer.background_processor << {
sql: safe_sql,
caller: caller,
logger: analyzer[:logger_instance],
tag: Thread.current[:_ar_analyzer_tag],
request_path: Thread.current[:_ar_analyzer_request_path]
}
end
end
end
super
end
|