rack-mini-profiler 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +10 -0
- data/README.md +2 -1
- data/lib/html/includes.css +5 -5
- data/lib/html/includes.js +38 -3
- data/lib/html/includes.scss +1 -1
- data/lib/html/includes.tmpl +5 -0
- data/lib/html/profile_handler.js +1 -1
- data/lib/mini_profiler/asset_version.rb +1 -1
- data/lib/mini_profiler/client_settings.rb +11 -12
- data/lib/mini_profiler/config.rb +17 -17
- data/lib/mini_profiler/context.rb +3 -3
- data/lib/mini_profiler/gc_profiler.rb +15 -16
- data/lib/mini_profiler/profiler.rb +50 -54
- data/lib/mini_profiler/profiling_methods.rb +4 -4
- data/lib/mini_profiler/storage/file_store.rb +10 -7
- data/lib/mini_profiler/storage/memcache_store.rb +4 -5
- data/lib/mini_profiler/storage/memory_store.rb +2 -3
- data/lib/mini_profiler/storage/redis_store.rb +2 -2
- data/lib/mini_profiler/timer_struct/base.rb +2 -2
- data/lib/mini_profiler/timer_struct/client.rb +6 -7
- data/lib/mini_profiler/timer_struct/custom.rb +4 -4
- data/lib/mini_profiler/timer_struct/page.rb +26 -25
- data/lib/mini_profiler/timer_struct/request.rb +25 -24
- data/lib/mini_profiler/timer_struct/sql.rb +20 -20
- data/lib/mini_profiler/version.rb +1 -1
- data/lib/mini_profiler_rails/railtie.rb +3 -3
- data/lib/patches/db/activerecord.rb +2 -2
- data/lib/patches/db/moped.rb +2 -2
- data/lib/patches/db/mysql2.rb +5 -5
- data/lib/patches/db/nobrainer.rb +1 -1
- data/lib/patches/db/pg.rb +34 -16
- data/lib/patches/db/riak.rb +11 -11
- data/lib/patches/db/rsolr.rb +2 -2
- data/rack-mini-profiler.gemspec +5 -4
- metadata +18 -4
@@ -6,7 +6,7 @@ module Rack
|
|
6
6
|
# A base class for timing structures
|
7
7
|
class Base
|
8
8
|
|
9
|
-
def initialize(attrs={})
|
9
|
+
def initialize(attrs = {})
|
10
10
|
@attributes = attrs
|
11
11
|
end
|
12
12
|
|
@@ -26,7 +26,7 @@ module Rack
|
|
26
26
|
def to_json(*a)
|
27
27
|
# this does could take in an option hash, but the only interesting there is max_nesting.
|
28
28
|
# if this becomes an option we could increase
|
29
|
-
::JSON.generate(
|
29
|
+
::JSON.generate(@attributes, max_nesting: 100)
|
30
30
|
end
|
31
31
|
|
32
32
|
def as_json(options = nil)
|
@@ -24,8 +24,7 @@ module Rack
|
|
24
24
|
wrapped
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
def initialize(env={})
|
27
|
+
def initialize(env = {})
|
29
28
|
super
|
30
29
|
end
|
31
30
|
|
@@ -62,21 +61,21 @@ module Rack
|
|
62
61
|
end
|
63
62
|
|
64
63
|
translated.each do |name, data|
|
65
|
-
h = {"Name" => name, "Start" => data[:start].to_i - baseTime}
|
64
|
+
h = { "Name" => name, "Start" => data[:start].to_i - baseTime }
|
66
65
|
h["Duration"] = data[:finish].to_i - data[:start].to_i if data[:finish]
|
67
66
|
timings.push(h)
|
68
67
|
end
|
69
68
|
|
70
|
-
clientTimes.keys.find_all{|k| k =~ /Start$/ }.each do |k|
|
69
|
+
clientTimes.keys.find_all { |k| k =~ /Start$/ }.each do |k|
|
71
70
|
start = clientTimes[k].to_i - baseTime
|
72
71
|
finish = clientTimes[k.sub(/Start$/, "End")].to_i - baseTime
|
73
72
|
duration = 0
|
74
73
|
duration = finish - start if finish > start
|
75
|
-
name = k.sub(/Start$/, "").split(/(?=[A-Z])/).map{|s| s.capitalize}.join(' ')
|
76
|
-
timings.push(
|
74
|
+
name = k.sub(/Start$/, "").split(/(?=[A-Z])/).map { |s| s.capitalize }.join(' ')
|
75
|
+
timings.push("Name" => name, "Start" => start, "Duration" => duration) if start >= 0
|
77
76
|
end
|
78
77
|
|
79
|
-
clientTimes.keys.find_all{|k| !(k =~ /(End|Start)$/)}.each do |k|
|
78
|
+
clientTimes.keys.find_all { |k| !(k =~ /(End|Start)$/) }.each do |k|
|
80
79
|
timings.push("Name" => k, "Start" => clientTimes[k].to_i - baseTime, "Duration" => -1)
|
81
80
|
end
|
82
81
|
|
@@ -12,10 +12,10 @@ module Rack
|
|
12
12
|
@type = type
|
13
13
|
start_millis = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) * 1000).to_i - page[:started]) - duration_ms
|
14
14
|
super(
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
15
|
+
type: type,
|
16
|
+
start_milliseconds: start_millis,
|
17
|
+
duration_milliseconds: duration_ms,
|
18
|
+
parent_timing_id: nil
|
19
19
|
)
|
20
20
|
end
|
21
21
|
end
|
@@ -17,28 +17,29 @@ module Rack
|
|
17
17
|
started = (Process.clock_gettime(Process::CLOCK_MONOTONIC) * 1000).to_i
|
18
18
|
machine_name = env['SERVER_NAME']
|
19
19
|
super(
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
20
|
+
id: timer_id,
|
21
|
+
name: page_name,
|
22
|
+
started: started,
|
23
|
+
started_at: started_at,
|
24
|
+
machine_name: machine_name,
|
25
|
+
level: 0,
|
26
|
+
user: "unknown user",
|
27
|
+
has_user_viewed: false,
|
28
|
+
client_timings: nil,
|
29
|
+
duration_milliseconds: 0,
|
30
|
+
has_trivial_timings: true,
|
31
|
+
has_all_trivial_timings: false,
|
32
|
+
trivial_duration_threshold_milliseconds: 2,
|
33
|
+
head: nil,
|
34
|
+
sql_count: 0,
|
35
|
+
duration_milliseconds_in_sql: 0,
|
36
|
+
has_sql_timings: true,
|
37
|
+
has_duplicate_sql_timings: false,
|
38
|
+
executed_readers: 0,
|
39
|
+
executed_scalars: 0,
|
40
|
+
executed_non_queries: 0,
|
41
|
+
custom_timing_names: [],
|
42
|
+
custom_timing_stats: {}
|
42
43
|
)
|
43
44
|
name = "#{env['REQUEST_METHOD']} http://#{env['SERVER_NAME']}:#{env['SERVER_PORT']}#{env['SCRIPT_NAME']}#{env['PATH_INFO']}"
|
44
45
|
self[:root] = TimerStruct::Request.createRoot(name, self)
|
@@ -70,9 +71,9 @@ module Rack
|
|
70
71
|
|
71
72
|
def extra_json
|
72
73
|
{
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
74
|
+
started: '/Date(%d)/' % @attributes[:started_at],
|
75
|
+
duration_milliseconds: @attributes[:root][:duration_milliseconds],
|
76
|
+
custom_timing_names: @attributes[:custom_timing_stats].keys.sort
|
76
77
|
}
|
77
78
|
end
|
78
79
|
end
|
@@ -17,28 +17,28 @@ module Rack
|
|
17
17
|
start_millis = (Process.clock_gettime(Process::CLOCK_MONOTONIC) * 1000).to_i - page[:started]
|
18
18
|
depth = parent ? parent.depth + 1 : 0
|
19
19
|
super(
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
20
|
+
id: MiniProfiler.generate_id,
|
21
|
+
name: name,
|
22
|
+
duration_milliseconds: 0,
|
23
|
+
duration_without_children_milliseconds: 0,
|
24
|
+
start_milliseconds: start_millis,
|
25
|
+
parent_timing_id: nil,
|
26
|
+
children: [],
|
27
|
+
has_children: false,
|
28
|
+
key_values: nil,
|
29
|
+
has_sql_timings: false,
|
30
|
+
has_duplicate_sql_timings: false,
|
31
|
+
trivial_duration_threshold_milliseconds: 2,
|
32
|
+
sql_timings: [],
|
33
|
+
sql_timings_duration_milliseconds: 0,
|
34
|
+
is_trivial: false,
|
35
|
+
is_root: false,
|
36
|
+
depth: depth,
|
37
|
+
executed_readers: 0,
|
38
|
+
executed_scalars: 0,
|
39
|
+
executed_non_queries: 0,
|
40
|
+
custom_timing_stats: {},
|
41
|
+
custom_timings: {}
|
42
42
|
)
|
43
43
|
@children_duration = 0
|
44
44
|
@start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
@@ -98,6 +98,7 @@ module Rack
|
|
98
98
|
self[:has_sql_timings] = true
|
99
99
|
self[:sql_timings_duration_milliseconds] += elapsed_ms
|
100
100
|
page[:duration_milliseconds_in_sql] += elapsed_ms
|
101
|
+
page[:sql_count] += 1
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
@@ -108,11 +109,11 @@ module Rack
|
|
108
109
|
self[:custom_timings][type] ||= []
|
109
110
|
self[:custom_timings][type].push(timer)
|
110
111
|
|
111
|
-
self[:custom_timing_stats][type] ||= {:
|
112
|
+
self[:custom_timing_stats][type] ||= { count: 0, duration: 0.0 }
|
112
113
|
self[:custom_timing_stats][type][:count] += 1
|
113
114
|
self[:custom_timing_stats][type][:duration] += elapsed_ms
|
114
115
|
|
115
|
-
page[:custom_timing_stats][type] ||= {:
|
116
|
+
page[:custom_timing_stats][type] ||= { count: 0, duration: 0.0 }
|
116
117
|
page[:custom_timing_stats][type][:count] += 1
|
117
118
|
page[:custom_timing_stats][type][:duration] += elapsed_ms
|
118
119
|
end
|
@@ -12,18 +12,18 @@ module Rack
|
|
12
12
|
unless skip_backtrace || duration_ms < Rack::MiniProfiler.config.backtrace_threshold_ms
|
13
13
|
# Allow us to filter the stack trace
|
14
14
|
stack_trace = "".dup
|
15
|
-
|
15
|
+
# Clean up the stack trace if there are options to do so
|
16
16
|
Kernel.caller.each do |ln|
|
17
|
-
ln.gsub!(Rack::MiniProfiler.config.backtrace_remove, '') if Rack::MiniProfiler.config.backtrace_remove
|
18
|
-
if full_backtrace
|
17
|
+
ln.gsub!(Rack::MiniProfiler.config.backtrace_remove, '') if Rack::MiniProfiler.config.backtrace_remove && !full_backtrace
|
18
|
+
if full_backtrace ||
|
19
19
|
(
|
20
20
|
(
|
21
|
-
Rack::MiniProfiler.config.backtrace_includes.nil?
|
22
|
-
Rack::MiniProfiler.config.backtrace_includes.any?{|regex| ln =~ regex}
|
23
|
-
)
|
21
|
+
Rack::MiniProfiler.config.backtrace_includes.nil? ||
|
22
|
+
Rack::MiniProfiler.config.backtrace_includes.any? { |regex| ln =~ regex }
|
23
|
+
) &&
|
24
24
|
(
|
25
|
-
Rack::MiniProfiler.config.backtrace_ignores.nil?
|
26
|
-
Rack::MiniProfiler.config.backtrace_ignores.none?{|regex| ln =~ regex}
|
25
|
+
Rack::MiniProfiler.config.backtrace_ignores.nil? ||
|
26
|
+
Rack::MiniProfiler.config.backtrace_ignores.none? { |regex| ln =~ regex }
|
27
27
|
)
|
28
28
|
)
|
29
29
|
stack_trace << ln << "\n"
|
@@ -35,15 +35,15 @@ module Rack
|
|
35
35
|
@page = page
|
36
36
|
start_millis = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) * 1000).to_i - page[:started]) - duration_ms
|
37
37
|
super(
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
38
|
+
execute_type: 3, # TODO
|
39
|
+
formatted_command_string: query,
|
40
|
+
stack_trace_snippet: stack_trace,
|
41
|
+
start_milliseconds: start_millis,
|
42
|
+
duration_milliseconds: duration_ms,
|
43
|
+
first_fetch_duration_milliseconds: duration_ms,
|
44
|
+
parameters: trim_binds(params),
|
45
|
+
parent_timing_id: nil,
|
46
|
+
is_duplicate: false
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
@@ -58,18 +58,18 @@ module Rack
|
|
58
58
|
def trim_binds(binds)
|
59
59
|
max_len = Rack::MiniProfiler.config.max_sql_param_length
|
60
60
|
return if binds.nil? || max_len == 0
|
61
|
-
return binds.map{|(name, val)| [name, val]} if max_len.nil?
|
61
|
+
return binds.map { |(name, val)| [name, val] } if max_len.nil?
|
62
62
|
binds.map do |(name, val)|
|
63
63
|
val ||= name
|
64
64
|
if val.nil? || val == true || val == false || val.kind_of?(Numeric)
|
65
65
|
# keep these parameters as is
|
66
66
|
elsif val.kind_of?(String)
|
67
|
-
val = val[0...max_len]+(max_len < val.length ? '...' : '') if max_len
|
67
|
+
val = val[0...max_len] + (max_len < val.length ? '...' : '') if max_len
|
68
68
|
else
|
69
69
|
val = val.class.name
|
70
70
|
end
|
71
71
|
if name.kind_of?(String)
|
72
|
-
name = name[0...max_len]+(max_len < name.length ? '...' : '') if max_len
|
72
|
+
name = name[0...max_len] + (max_len < name.length ? '...' : '') if max_len
|
73
73
|
end
|
74
74
|
[name, val]
|
75
75
|
end
|
@@ -44,7 +44,7 @@ module Rack::MiniProfilerRails
|
|
44
44
|
base_path = Rails.application.config.paths['tmp'].first rescue "#{Rails.root}/tmp"
|
45
45
|
tmp = base_path + '/miniprofiler'
|
46
46
|
|
47
|
-
c.storage_options = {:
|
47
|
+
c.storage_options = { path: tmp }
|
48
48
|
c.storage = Rack::MiniProfiler::FileStore
|
49
49
|
end
|
50
50
|
|
@@ -58,10 +58,10 @@ module Rack::MiniProfilerRails
|
|
58
58
|
|
59
59
|
# Attach to various Rails methods
|
60
60
|
ActiveSupport.on_load(:action_controller) do
|
61
|
-
::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"}
|
61
|
+
::Rack::MiniProfiler.profile_method(ActionController::Base, :process) { |action| "Executing action: #{action}" }
|
62
62
|
end
|
63
63
|
ActiveSupport.on_load(:action_view) do
|
64
|
-
::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{@virtual_path}"}
|
64
|
+
::Rack::MiniProfiler.profile_method(ActionView::Template, :render) { |x, y| "Rendering: #{@virtual_path}" }
|
65
65
|
end
|
66
66
|
|
67
67
|
@already_initialized = true
|
@@ -20,7 +20,7 @@ module Rack
|
|
20
20
|
# map ActiveRecord::Relation::QueryAttribute to [name, value]
|
21
21
|
params = binds.map { |c| c.kind_of?(Array) ? [c.first, c.last] : [c.name, c.value] }
|
22
22
|
if (skip = Rack::MiniProfiler.config.skip_sql_param_names)
|
23
|
-
params.map { |(n,v)| n =~ skip ? [n, nil] : [n, v] }
|
23
|
+
params.map { |(n, v)| n =~ skip ? [n, nil] : [n, v] }
|
24
24
|
else
|
25
25
|
params
|
26
26
|
end
|
@@ -34,7 +34,7 @@ module Rack
|
|
34
34
|
rval = log_without_miniprofiler(*args, &block)
|
35
35
|
|
36
36
|
# Don't log schema queries if the option is set
|
37
|
-
return rval if Rack::MiniProfiler.config.skip_schema_queries
|
37
|
+
return rval if Rack::MiniProfiler.config.skip_schema_queries && name =~ (/SCHEMA/)
|
38
38
|
|
39
39
|
elapsed_time = SqlPatches.elapsed_time(start)
|
40
40
|
Rack::MiniProfiler.record_sql(sql, elapsed_time, binds_to_params(binds))
|
data/lib/patches/db/moped.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# Mongoid 3 patches
|
4
4
|
class Moped::Node
|
5
5
|
alias_method :process_without_profiling, :process
|
6
|
-
def process(*args
|
7
|
-
return process_without_profiling(*args
|
6
|
+
def process(*args, &blk)
|
7
|
+
return process_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
8
8
|
|
9
9
|
result, _record = SqlPatches.record_sql(args[0].log_inspect) do
|
10
10
|
process_without_profiling(*args, &blk)
|
data/lib/patches/db/mysql2.rb
CHANGED
@@ -8,7 +8,7 @@ class Mysql2::Result
|
|
8
8
|
return each_without_profiling(*args, &blk) unless defined?(@miniprofiler_sql_id)
|
9
9
|
|
10
10
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
11
|
-
result = each_without_profiling(*args
|
11
|
+
result = each_without_profiling(*args, &blk)
|
12
12
|
elapsed_time = SqlPatches.elapsed_time(start)
|
13
13
|
|
14
14
|
@miniprofiler_sql_id.report_reader_duration(elapsed_time)
|
@@ -18,11 +18,11 @@ end
|
|
18
18
|
|
19
19
|
class Mysql2::Client
|
20
20
|
alias_method :query_without_profiling, :query
|
21
|
-
def query(*args
|
22
|
-
return query_without_profiling(*args
|
21
|
+
def query(*args, &blk)
|
22
|
+
return query_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
23
23
|
|
24
|
-
result, record = SqlPatches.record_sql(
|
25
|
-
query_without_profiling(*args
|
24
|
+
result, record = SqlPatches.record_sql(args[0]) do
|
25
|
+
query_without_profiling(*args, &blk)
|
26
26
|
end
|
27
27
|
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
28
28
|
result
|
data/lib/patches/db/nobrainer.rb
CHANGED
@@ -17,7 +17,7 @@ class Rack::MiniProfiler::NoBrainerProfiler
|
|
17
17
|
# query << "(#{NoBrainer::RQL.type_of(env[:query]).to_s}) "
|
18
18
|
|
19
19
|
query << "NOT USING INDEX: " if not_indexed
|
20
|
-
query << env[:query].inspect.
|
20
|
+
query << env[:query].inspect.delete("\n").gsub(/ +/, ' ') + " "
|
21
21
|
|
22
22
|
if env[:exception]
|
23
23
|
query << "exception: #{env[:exception].class} #{env[:exception].message.split("\n").first} "
|
data/lib/patches/db/pg.rb
CHANGED
@@ -8,7 +8,7 @@ class PG::Result
|
|
8
8
|
def values(*args, &blk)
|
9
9
|
return values_without_profiling(*args, &blk) unless defined?(@miniprofiler_sql_id)
|
10
10
|
mp_report_sql do
|
11
|
-
values_without_profiling(*args
|
11
|
+
values_without_profiling(*args , &blk)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -35,7 +35,11 @@ class PG::Connection
|
|
35
35
|
alias_method :send_query_prepared_without_profiling, :send_query_prepared
|
36
36
|
alias_method :prepare_without_profiling, :prepare
|
37
37
|
|
38
|
-
|
38
|
+
if Gem::Version.new(PG::VERSION) >= Gem::Version.new("1.1.0")
|
39
|
+
alias_method :exec_params_without_profiling, :exec_params
|
40
|
+
end
|
41
|
+
|
42
|
+
def prepare(*args, &blk)
|
39
43
|
# we have no choice but to do this here,
|
40
44
|
# if we do the check for profiling first, our cache may miss critical stuff
|
41
45
|
|
@@ -44,15 +48,15 @@ class PG::Connection
|
|
44
48
|
# dont leak more than 10k ever
|
45
49
|
@prepare_map = {} if @prepare_map.length > 1000
|
46
50
|
|
47
|
-
return prepare_without_profiling(*args
|
48
|
-
prepare_without_profiling(*args
|
51
|
+
return prepare_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
52
|
+
prepare_without_profiling(*args, &blk)
|
49
53
|
end
|
50
54
|
|
51
|
-
def exec(*args
|
52
|
-
return exec_without_profiling(*args
|
55
|
+
def exec(*args, &blk)
|
56
|
+
return exec_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
53
57
|
|
54
58
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
55
|
-
result = exec_without_profiling(*args
|
59
|
+
result = exec_without_profiling(*args, &blk)
|
56
60
|
elapsed_time = SqlPatches.elapsed_time(start)
|
57
61
|
record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
|
58
62
|
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
@@ -60,11 +64,25 @@ class PG::Connection
|
|
60
64
|
result
|
61
65
|
end
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
if Gem::Version.new(PG::VERSION) >= Gem::Version.new("1.1.0")
|
68
|
+
def exec_params(*args, &blk)
|
69
|
+
return exec_params_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
70
|
+
|
71
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
72
|
+
result = exec_params_without_profiling(*args, &blk)
|
73
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
74
|
+
record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
|
75
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
76
|
+
|
77
|
+
result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def exec_prepared(*args, &blk)
|
82
|
+
return exec_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
65
83
|
|
66
84
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
67
|
-
result = exec_prepared_without_profiling(*args
|
85
|
+
result = exec_prepared_without_profiling(*args, &blk)
|
68
86
|
elapsed_time = SqlPatches.elapsed_time(start)
|
69
87
|
mapped = args[0]
|
70
88
|
mapped = @prepare_map[mapped] || args[0] if @prepare_map
|
@@ -74,11 +92,11 @@ class PG::Connection
|
|
74
92
|
result
|
75
93
|
end
|
76
94
|
|
77
|
-
def send_query_prepared(*args
|
78
|
-
return send_query_prepared_without_profiling(*args
|
95
|
+
def send_query_prepared(*args, &blk)
|
96
|
+
return send_query_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
79
97
|
|
80
98
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
81
|
-
result = send_query_prepared_without_profiling(*args
|
99
|
+
result = send_query_prepared_without_profiling(*args, &blk)
|
82
100
|
elapsed_time = SqlPatches.elapsed_time(start)
|
83
101
|
mapped = args[0]
|
84
102
|
mapped = @prepare_map[mapped] || args[0] if @prepare_map
|
@@ -88,11 +106,11 @@ class PG::Connection
|
|
88
106
|
result
|
89
107
|
end
|
90
108
|
|
91
|
-
def async_exec(*args
|
92
|
-
return async_exec_without_profiling(*args
|
109
|
+
def async_exec(*args, &blk)
|
110
|
+
return async_exec_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
93
111
|
|
94
112
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
95
|
-
result = exec_without_profiling(*args
|
113
|
+
result = exec_without_profiling(*args, &blk)
|
96
114
|
elapsed_time = SqlPatches.elapsed_time(start)
|
97
115
|
record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
|
98
116
|
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|