Module: PG::Connection::MiniProfiler
- Included in:
- PG::Connection
- Defined in:
- lib/patches/db/pg/prepend.rb
Instance Method Summary collapse
- #async_exec(*args, &blk) ⇒ Object
- #exec(*args, &blk) ⇒ Object
- #exec_params(*args, &blk) ⇒ Object
- #exec_prepared(*args, &blk) ⇒ Object
- #prepare(*args, &blk) ⇒ Object
- #send_query_prepared(*args, &blk) ⇒ Object
Instance Method Details
#async_exec(*args, &blk) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/patches/db/pg/prepend.rb', line 100 def async_exec(*args, &blk) return super unless SqlPatches.should_measure? start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = super elapsed_time = SqlPatches.elapsed_time(start) record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#exec(*args, &blk) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/patches/db/pg/prepend.rb', line 46 def exec(*args, &blk) return super unless SqlPatches.should_measure? start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = super elapsed_time = SqlPatches.elapsed_time(start) record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#exec_params(*args, &blk) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/patches/db/pg/prepend.rb', line 59 def exec_params(*args, &blk) return super unless SqlPatches.should_measure? start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = super elapsed_time = SqlPatches.elapsed_time(start) record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#exec_prepared(*args, &blk) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/patches/db/pg/prepend.rb', line 72 def exec_prepared(*args, &blk) return super unless SqlPatches.should_measure? start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = super elapsed_time = SqlPatches.elapsed_time(start) mapped = args[0] mapped = @prepare_map[mapped] || args[0] if @prepare_map record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#prepare(*args, &blk) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/patches/db/pg/prepend.rb', line 33 def prepare(*args, &blk) # we have no choice but to do this here, # if we do the check for profiling first, our cache may miss critical stuff @prepare_map ||= {} @prepare_map[args[0]] = args[1] # dont leak more than 10k ever @prepare_map = {} if @prepare_map.length > 1000 return super unless SqlPatches.should_measure? super end |
#send_query_prepared(*args, &blk) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/patches/db/pg/prepend.rb', line 86 def send_query_prepared(*args, &blk) return super unless SqlPatches.should_measure? start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = super elapsed_time = SqlPatches.elapsed_time(start) mapped = args[0] mapped = @prepare_map[mapped] || args[0] if @prepare_map record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |