rack-mini-profiler 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +10 -0
- data/lib/html/includes.tmpl +1 -1
- data/lib/html/speedscope/README.md +2 -2
- data/lib/html/speedscope/fonts/source-code-pro-regular.css +8 -0
- data/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff +0 -0
- data/lib/html/speedscope/fonts/source-code-pro-v13-regular.woff2 +0 -0
- data/lib/html/speedscope/index.html +1 -1
- data/lib/html/vendor.js +1 -1
- data/lib/mini_profiler/asset_version.rb +1 -1
- data/lib/mini_profiler/profiling_methods.rb +3 -1
- data/lib/mini_profiler/version.rb +1 -1
- data/lib/patches/db/mysql2.rb +4 -27
- data/lib/patches/db/mysql2/alias_method.rb +30 -0
- data/lib/patches/db/mysql2/prepend.rb +34 -0
- data/lib/prepend_mysql2_patch.rb +5 -0
- data/rack-mini-profiler.gemspec +1 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 287f0fe8da1845abde81f60250c960808168f0d278cf905786293c584fe78c23
|
4
|
+
data.tar.gz: c43613852efe89a7e59c642220b4609b086190473a0c2c5a83ead3b1abbdce9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4944a4bbf9021b4639dc18d5e13d6f901eef47785b1e66ac37b261307cf82f70dd5ebc242fb099fecada4c450594155e600150baedfd7cb2b1d7f7b7527ef69
|
7
|
+
data.tar.gz: ba0ee401a63f3fe3a27acc1812d790a1e11de26f6d6ffd38d34730bfec3ecf26c96f20f9912fe071917a31a346115c10cd959bff35516624d3f816c5aa84426c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -78,6 +78,16 @@ gem 'rack-mini-profiler', require: ['prepend_net_http_patch']
|
|
78
78
|
|
79
79
|
This conflict happens when a ruby method is patched twice, once using module prepend, and once using method aliasing. See this [ruby issue](https://bugs.ruby-lang.org/issues/11120) for details. The fix is to apply all patches the same way. Mini Profiler by default will apply its patch using method aliasing, but you can change that to module prepend by adding `require: ['prepend_net_http_patch']` to the gem line as shown above.
|
80
80
|
|
81
|
+
#### `peek-mysql2` stack level too deep errors
|
82
|
+
|
83
|
+
If you use peek-mysql2 with Rails >= 5, you'll need to use this gem spec in your Gemfile:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
gem 'rack-mini-profiler', require: ['prepend_mysql2_patch', 'rack-mini-profiler']
|
87
|
+
```
|
88
|
+
|
89
|
+
This should not be necessary with Rails < 5 because peek-mysql2 hooks into mysql2 gem in different ways depending on your Rails version.
|
90
|
+
|
81
91
|
#### Rails and manual initialization
|
82
92
|
|
83
93
|
In case you need to make sure rack_mini_profiler is initialized after all other gems, or you want to execute some code before rack_mini_profiler required:
|
data/lib/html/includes.tmpl
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
This directory contains the necessary files and assets to run [speedscope](https://github.com/jlfwong/speedscope).
|
1
|
+
This directory contains the necessary files and assets to run [speedscope](https://github.com/jlfwong/speedscope). The files come from a ZIP file that can be downloaded from the releases page of the speedscope repository on GitHub. If you wish to upgrade speedscope to the latest version, run `bundle exec rake speedscope_upgrade` in the root directory of this repository.
|
2
2
|
|
3
|
-
|
3
|
+
The rake task will download the ZIP file of the latest speedscope release from Github, remove the old files from the `lib/html/speedscope` directory and extract the ZIP file into the same directory. It will also make a small change to the `index.html` file to replace a link to a Google Fonts stylesheet with a link to a local copy in the `fonts` directory. This is done to make sure speedscope doesn't load any assets from third-parties so that it can work when you're on an intranet.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
@font-face {
|
2
|
+
font-family: 'Source Code Pro';
|
3
|
+
font-style: normal;
|
4
|
+
font-weight: 400;
|
5
|
+
src: local(''),
|
6
|
+
url('./source-code-pro-v13-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
|
7
|
+
url('./source-code-pro-v13-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
|
8
|
+
}
|
Binary file
|
Binary file
|
@@ -1,2 +1,2 @@
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>speedscope</title><link href="
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>speedscope</title><link href="fonts/source-code-pro-regular.css" rel="stylesheet"><script></script><link rel="stylesheet" href="reset.8c46b7a1.css"><link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.bc503437.png"><link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.f74b3187.png"></head><body> <script src="speedscope.44364064.js"></script>
|
2
2
|
</body></html>
|
data/lib/html/vendor.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
MiniProfiler.templates = {};
|
8
8
|
MiniProfiler.templates["profilerTemplate"] = function anonymous(it
|
9
9
|
) {
|
10
|
-
var out=' <div class="profiler-result"> <div class="profiler-button ';if(it.has_duplicate_sql_timings){out+='profiler-warning';}out+='"> ';if(it.has_duplicate_sql_timings){out+='<span class="profiler-nuclear">!</span>';}out+=' <span class="profiler-number"> '+( MiniProfiler.formatDuration(it.duration_milliseconds))+' <span class="profiler-unit">ms</span> </span> ';if(MiniProfiler.showTotalSqlCount()){out+=' <span class="profiler-number"> '+( it.sql_count)+' <span class="profiler-unit">sql</span> </span> ';}out+=' </div> <div class="profiler-popup"> <div class="profiler-info"> <span class="profiler-name"> '+( it.name)+' <span class="profiler-overall-duration">('+( MiniProfiler.formatDuration(it.duration_milliseconds))+' ms)</span> </span> <span class="profiler-server-time">'+( it.machine_name)+' on '+( MiniProfiler.renderDate(it.started_formatted))+'</span> </div> <div class="profiler-output"> <table class="profiler-timings"> <thead> <tr> <th
|
10
|
+
var out=' <div class="profiler-result"> <div class="profiler-button ';if(it.has_duplicate_sql_timings){out+='profiler-warning';}out+='"> ';if(it.has_duplicate_sql_timings){out+='<span class="profiler-nuclear">!</span>';}out+=' <span class="profiler-number"> '+( MiniProfiler.formatDuration(it.duration_milliseconds))+' <span class="profiler-unit">ms</span> </span> ';if(MiniProfiler.showTotalSqlCount()){out+=' <span class="profiler-number"> '+( it.sql_count)+' <span class="profiler-unit">sql</span> </span> ';}out+=' </div> <div class="profiler-popup"> <div class="profiler-info"> <span class="profiler-name"> '+( it.name)+' <span class="profiler-overall-duration">('+( MiniProfiler.formatDuration(it.duration_milliseconds))+' ms)</span> </span> <span class="profiler-server-time">'+( it.machine_name)+' on '+( MiniProfiler.renderDate(it.started_formatted))+'</span> </div> <div class="profiler-output"> <table class="profiler-timings"> <thead> <tr> <th>event</th> <th>duration (ms)</th> <th class="profiler-duration-with-children">with children (ms)</th> <th class="time-from-start">from start (ms)</th> ';if(it.has_sql_timings){out+=' <th colspan="2">query time (ms)</th> ';}out+=' ';var arr1=it.custom_timing_names;if(arr1){var value,i1=-1,l1=arr1.length-1;while(i1<l1){value=arr1[i1+=1];out+=' <th colspan="2">'+( value.toLowerCase() )+' (ms)</th> ';} } out+=' </tr> </thead> <tbody> '+( MiniProfiler.templates.timingTemplate({timing: it.root, page: it}) )+' </tbody> <tfoot> <tr> <td colspan="3"> ';if(!it.client_timings){out+=' '+( MiniProfiler.templates.linksTemplate({timing: it.root, page: it}) )+' ';}out+=' <a class="profiler-toggle-duration-with-children" title="toggles column with aggregate child durations">show time with children</a> <a class="profiler-snapshots-page-link" title="Go to snapshots page" href="'+( MiniProfiler.options.path )+'snapshots">snapshots</a> </td> ';if(it.has_sql_timings){out+=' <td colspan="2" class="profiler-number profiler-percent-in-sql" title="'+( MiniProfiler.getSqlTimingsCount(it.root) )+' queries spent '+( MiniProfiler.formatDuration(it.duration_milliseconds_in_sql) )+' ms of total request time"> '+( MiniProfiler.formatDuration(it.duration_milliseconds_in_sql / it.duration_milliseconds * 100) )+' <span class="profiler-unit">% in sql</span> </td> ';}out+=' ';var arr2=it.custom_timing_names;if(arr2){var value,i2=-1,l2=arr2.length-1;while(i2<l2){value=arr2[i2+=1];out+=' <td colspan="2" class="profiler-number profiler-percentage-in-sql" title="'+( it.custom_timing_stats[value].count )+' '+( value.toLowerCase() )+' invocations spent '+( MiniProfiler.formatDuration(it.custom_timing_stats[value].duration) )+' ms of total request time"> '+( MiniProfiler.formatDuration(it.custom_timing_stats[value].duration / it.duration_milliseconds * 100) )+' <span class="profiler-unit">% in '+( value.toLowerCase() )+'</span> </td> ';} } out+=' </tr> </tfoot> </table> ';if(it.client_timings){out+=' <table class="profiler-timings profiler-client-timings"> <thead> <tr> <th>client event</th> <th>duration (ms)</th> <th>from start (ms)</th> </tr> </thead> <tbody> ';var arr3=MiniProfiler.getClientTimings(it.client_timings);if(arr3){var value,i3=-1,l3=arr3.length-1;while(i3<l3){value=arr3[i3+=1];out+=' <tr class="';if(value.isTrivial){out+='profiler-trivial';}out+='"> <td class="profiler-label">'+( value.name )+'</td> <td class="profiler-duration"> ';if(value.duration >= 0){out+=' <span class="profiler-unit"></span>'+( MiniProfiler.formatDuration(value.duration) )+' ';}out+=' </td> <td class="profiler-duration time-from-start"> <span class="profiler-unit">+</span>'+( MiniProfiler.formatDuration(value.start) )+' </td> </tr> ';} } out+=' </tbody> <tfoot> <td colspan="3"> '+( MiniProfiler.templates.linksTemplate({timing: it.root, page: it}) )+' </td> </tfoot> </table> ';}out+=' ';if(it.custom_fields && Object.keys(it.custom_fields).length > 0){out+=' <p class="custom-fields-title">Snapshot custom fields</p> <table class="profiler-timings"> <tbody> ';var arr4=Object.keys(it.custom_fields);if(arr4){var key,i4=-1,l4=arr4.length-1;while(i4<l4){key=arr4[i4+=1];out+=' <tr> <td class="profiler-label">'+( key )+'</td> <td class="profiler-label">'+( it.custom_fields[key] )+'</td> </tr> ';} } out+=' </tbody> </table> ';}out+=' </div> </div> ';if(it.has_sql_timings){out+=' <div class="profiler-queries"> <table> <thead> <tr> <th style="text-align:right">step<br />time from start<br />query type<br />duration</th> <th style="text-align:left">call stack<br />query</th> </tr> </thead> <tbody> ';var arr5=MiniProfiler.getSqlTimings(it.root);if(arr5){var value,index=-1,l5=arr5.length-1;while(index<l5){value=arr5[index+=1];out+=' '+( MiniProfiler.templates.sqlGapTemplate({g: value.prevGap}) )+' '+( MiniProfiler.templates.sqlTimingTemplate({i: index, s: value}) )+' ';if(value.nextGap){out+=' '+( MiniProfiler.templates.sqlGapTemplate({g: value.nextGap}) )+' ';}out+=' ';} } out+=' </tbody> </table> <p class="profiler-trivial-gap-container"> <a class="profiler-toggle-trivial-gaps">show trivial gaps</a> </p> </div> ';}out+=' </div>';return out;
|
11
11
|
}
|
12
12
|
MiniProfiler.templates["linksTemplate"] = function anonymous(it
|
13
13
|
) {
|
@@ -115,6 +115,9 @@ module Rack
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
118
|
+
if klass.respond_to?(:ruby2_keywords, true)
|
119
|
+
klass.send(:ruby2_keywords, with_profiling)
|
120
|
+
end
|
118
121
|
klass.send :alias_method, method, with_profiling
|
119
122
|
end
|
120
123
|
|
@@ -154,7 +157,6 @@ module Rack
|
|
154
157
|
def clean_method_name(method)
|
155
158
|
method.to_s.gsub(/[\?\!]/, "")
|
156
159
|
end
|
157
|
-
|
158
160
|
end
|
159
161
|
end
|
160
162
|
end
|
data/lib/patches/db/mysql2.rb
CHANGED
@@ -1,30 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
alias_method
|
7
|
-
def each(*args, &blk)
|
8
|
-
return each_without_profiling(*args, &blk) unless defined?(@miniprofiler_sql_id)
|
9
|
-
|
10
|
-
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
11
|
-
result = each_without_profiling(*args, &blk)
|
12
|
-
elapsed_time = SqlPatches.elapsed_time(start)
|
13
|
-
|
14
|
-
@miniprofiler_sql_id.report_reader_duration(elapsed_time)
|
15
|
-
result
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class Mysql2::Client
|
20
|
-
alias_method :query_without_profiling, :query
|
21
|
-
def query(*args, &blk)
|
22
|
-
return query_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
23
|
-
|
24
|
-
result, record = SqlPatches.record_sql(args[0]) do
|
25
|
-
query_without_profiling(*args, &blk)
|
26
|
-
end
|
27
|
-
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
28
|
-
result
|
29
|
-
end
|
3
|
+
if defined?(Rack::MINI_PROFILER_PREPEND_MYSQL2_PATCH)
|
4
|
+
require "patches/db/mysql2/prepend"
|
5
|
+
else
|
6
|
+
require "patches/db/mysql2/alias_method"
|
30
7
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The best kind of instrumentation is in the actual db provider, however we don't want to double instrument
|
4
|
+
|
5
|
+
class Mysql2::Result
|
6
|
+
alias_method :each_without_profiling, :each
|
7
|
+
def each(*args, &blk)
|
8
|
+
return each_without_profiling(*args, &blk) unless defined?(@miniprofiler_sql_id)
|
9
|
+
|
10
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
11
|
+
result = each_without_profiling(*args, &blk)
|
12
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
13
|
+
|
14
|
+
@miniprofiler_sql_id.report_reader_duration(elapsed_time)
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Mysql2::Client
|
20
|
+
alias_method :query_without_profiling, :query
|
21
|
+
def query(*args, &blk)
|
22
|
+
return query_without_profiling(*args, &blk) unless SqlPatches.should_measure?
|
23
|
+
|
24
|
+
result, record = SqlPatches.record_sql(args[0]) do
|
25
|
+
query_without_profiling(*args, &blk)
|
26
|
+
end
|
27
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
28
|
+
result
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Mysql2::Result
|
4
|
+
module MiniProfiler
|
5
|
+
def each(*args, &blk)
|
6
|
+
return super unless defined?(@miniprofiler_sql_id)
|
7
|
+
|
8
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
9
|
+
result = super
|
10
|
+
elapsed_time = SqlPatches.elapsed_time(start)
|
11
|
+
|
12
|
+
@miniprofiler_sql_id.report_reader_duration(elapsed_time)
|
13
|
+
result
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
prepend MiniProfiler
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mysql2::Client
|
21
|
+
module MiniProfiler
|
22
|
+
def query(*args, &blk)
|
23
|
+
return super unless SqlPatches.should_measure?
|
24
|
+
|
25
|
+
result, record = SqlPatches.record_sql(args[0]) do
|
26
|
+
super
|
27
|
+
end
|
28
|
+
result.instance_variable_set("@miniprofiler_sql_id", record) if result
|
29
|
+
result
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
prepend MiniProfiler
|
34
|
+
end
|
data/rack-mini-profiler.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mini-profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -236,6 +236,20 @@ dependencies:
|
|
236
236
|
- - '='
|
237
237
|
- !ruby/object:Gem::Version
|
238
238
|
version: 3.9.1
|
239
|
+
- !ruby/object:Gem::Dependency
|
240
|
+
name: rubyzip
|
241
|
+
requirement: !ruby/object:Gem::Requirement
|
242
|
+
requirements:
|
243
|
+
- - ">="
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '0'
|
246
|
+
type: :development
|
247
|
+
prerelease: false
|
248
|
+
version_requirements: !ruby/object:Gem::Requirement
|
249
|
+
requirements:
|
250
|
+
- - ">="
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '0'
|
239
253
|
description: Profiling toolkit for Rack applications with Rails integration. Client
|
240
254
|
Side profiling, DB profiling and Server profiling.
|
241
255
|
email: sam.saffron@gmail.com
|
@@ -267,6 +281,9 @@ files:
|
|
267
281
|
- lib/html/speedscope/favicon-16x16.f74b3187.png
|
268
282
|
- lib/html/speedscope/favicon-32x32.bc503437.png
|
269
283
|
- lib/html/speedscope/file-format-schema.json
|
284
|
+
- lib/html/speedscope/fonts/source-code-pro-regular.css
|
285
|
+
- lib/html/speedscope/fonts/source-code-pro-v13-regular.woff
|
286
|
+
- lib/html/speedscope/fonts/source-code-pro-v13-regular.woff2
|
270
287
|
- lib/html/speedscope/import.cf0fa83f.js
|
271
288
|
- lib/html/speedscope/index.html
|
272
289
|
- lib/html/speedscope/release.txt
|
@@ -300,6 +317,8 @@ files:
|
|
300
317
|
- lib/patches/db/mongo.rb
|
301
318
|
- lib/patches/db/moped.rb
|
302
319
|
- lib/patches/db/mysql2.rb
|
320
|
+
- lib/patches/db/mysql2/alias_method.rb
|
321
|
+
- lib/patches/db/mysql2/prepend.rb
|
303
322
|
- lib/patches/db/neo4j.rb
|
304
323
|
- lib/patches/db/nobrainer.rb
|
305
324
|
- lib/patches/db/oracle_enhanced.rb
|
@@ -310,6 +329,7 @@ files:
|
|
310
329
|
- lib/patches/db/sequel.rb
|
311
330
|
- lib/patches/net_patches.rb
|
312
331
|
- lib/patches/sql_patches.rb
|
332
|
+
- lib/prepend_mysql2_patch.rb
|
313
333
|
- lib/prepend_net_http_patch.rb
|
314
334
|
- lib/rack-mini-profiler.rb
|
315
335
|
- rack-mini-profiler.gemspec
|