rack-mini-profiler 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7fcca7a28de2898e8e320f2f94db5d96eee3128b9be7a48053e472036a6ef95
4
- data.tar.gz: 3a21bb993d77ef33baca78135716ab0e44dfbd28eefbb8874bae0b9a715ccb3f
3
+ metadata.gz: 15ea5fda4e557abe1cf4415087762e907f1ab3d1f80c900e1616e3d7c9e8d0aa
4
+ data.tar.gz: 4863e737b3441b208689ab8f2ba0c624af976c0ab3210030d91c4cbfd93d5e55
5
5
  SHA512:
6
- metadata.gz: 2b4a31ef4e964fbd76646425d1ff16007c56d77360c6ad1f6923e753cd8830614098867ce06d5a554810564674b654b8868b1cdddc9c815942e25314459b3de4
7
- data.tar.gz: fb3a9d99bb23a5e5d7b1518cd122a4240658b6c0c5d0c06f1852ddf472e9761cf9e46db5ce6cdcd92d574ec81ec3789f42aee51fe9ee20d8f587b51059cd55e1
6
+ metadata.gz: 22e9207e79c9bdeb0d7de0646f05fd52a3c70420b47c1498f37bfca6257e395e636d39f2745c27d4dc7272edd13a9983f5ddaf6205f4b22ce79af4e4638c9d44
7
+ data.tar.gz: f47ed39a7ba3fe823e57cea88e20b130644961924aedcb8e35a30d649b41eb2003bc36017dc42615486767d6b370b4630037f0da769d3c698681969eed03b89e
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.3 - 2020-07-29
4
+
5
+ - [FIX] support for deprecation free Redis 4.2
6
+ - [FEATURE] skip /packs when serving static assets
7
+ - [FEATURE] allow Net::HTTP patch to be applied with either prerpend or alias
8
+
3
9
  ## 2.0.2 - 2020-05-25
4
10
 
5
11
  - [FIX] client timings were not showing up when you clicked show trivial
data/README.md CHANGED
@@ -29,7 +29,7 @@ If you feel like taking on any of this start an issue and update us on your prog
29
29
 
30
30
  ## Installation
31
31
 
32
- Install/add to Gemfile in Ruby 2.3+
32
+ Install/add to Gemfile in Ruby 2.4+
33
33
 
34
34
  ```ruby
35
35
  gem 'rack-mini-profiler'
@@ -65,6 +65,22 @@ If you don't want to manually require Mini Profiler:
65
65
  gem 'rack-mini-profiler', require: ['enable_rails_patches', 'rack-mini-profiler']
66
66
  ```
67
67
 
68
+ #### `Net::HTTP` stack level too deep errors
69
+
70
+ If you start seeing `SystemStackError: stack level too deep` errors from `Net::HTTP` after installing Mini Profiler, this means there is another patch for `Net::HTTP#request` that conflicts with Mini Profiler's patch in your application. To fix this, change `rack-mini-profiler` gem line in your `Gemfile` to the following:
71
+
72
+ ```ruby
73
+ gem 'rack-mini-profiler', require: ['prepend_net_http_patch', 'rack-mini-profiler']
74
+ ```
75
+
76
+ If you currently have `require: false`, remove the `'rack-mini-profiler'` string from the `require` array above so the gem line becomes like this:
77
+
78
+ ```ruby
79
+ gem 'rack-mini-profiler', require: ['prepend_net_http_patch']
80
+ ```
81
+
82
+ 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.
83
+
68
84
  #### Rails and manual initialization
69
85
 
70
86
  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:
@@ -329,7 +345,7 @@ Option|Default|Description
329
345
  pre_authorize_cb|Rails: dev only<br>Rack: always on|A lambda callback that returns true to make mini_profiler visible on a given request.
330
346
  position|`'top-left'`|Display mini_profiler on `'top-right'`, `'top-left'`, `'bottom-right'` or `'bottom-left'`.
331
347
  skip_paths|`[]`|Paths that skip profiling.
332
- skip_schema_queries|Rails dev: `'true'`<br>Othwerwise: `'false'`|`'true'` to log schema queries.
348
+ skip_schema_queries|Rails dev: `true`<br>Othwerwise: `false`|`true` to skip schema queries.
333
349
  auto_inject|`true`|`true` to inject the miniprofiler script in the page.
334
350
  backtrace_ignores|`[]`|Regexes of lines to be removed from backtraces.
335
351
  backtrace_includes|Rails: `[/^\/?(app\|config\|lib\|test)/]`<br>Rack: `[]`|Regexes of lines to keep in backtraces.
@@ -345,32 +361,13 @@ html_container|`body`|The HTML container (as a jQuery selector) to inject the mi
345
361
  show_total_sql_count|`false`|Displays the total number of SQL executions.
346
362
  enable_advanced_debugging_tools|`false`|Enables sensitive debugging tools that can be used via the UI. In production we recommend keeping this disabled as memory and environment debugging tools can expose contents of memory that may contain passwords.
347
363
 
348
- ### Custom middleware ordering (required if using `Rack::Deflate` with Rails)
349
-
350
- If you are using `Rack::Deflate` with rails and rack-mini-profiler in its default configuration,
351
- `Rack::MiniProfiler` will be injected (as always) at position 0 in the middleware stack. This
352
- will result in it attempting to inject html into the already-compressed response body. To fix this,
353
- the middleware ordering must be overriden.
354
-
355
- To do this, first add `, require: false` to the gemfile entry for rack-mini-profiler.
356
- This will prevent the railtie from running. Then, customize the initialization
357
- in the initializer like so:
358
-
359
- ```ruby
360
- require 'rack-mini-profiler'
361
-
362
- Rack::MiniProfilerRails.initialize!(Rails.application)
363
-
364
- Rails.application.middleware.delete(Rack::MiniProfiler)
365
- Rails.application.middleware.insert_after(Rack::Deflater, Rack::MiniProfiler)
366
- ```
367
-
368
- Deleting the middleware and then reinserting it is a bit inelegant, but
369
- a sufficient and costless solution. It is possible that rack-mini-profiler might
370
- support this scenario more directly if it is found that
371
- there is significant need for this confriguration or that
372
- the above recipe causes problems.
364
+ ### Using MiniProfiler with `Rack::Deflate` middleware
373
365
 
366
+ If you are using `Rack::Deflate` with Rails and `rack-mini-profiler` in its default configuration,
367
+ `Rack::MiniProfiler` will be injected (as always) at position 0 in the middleware stack,
368
+ which means it will run after `Rack::Deflate` on response processing. To prevent attempting to inject
369
+ HTML in already compressed response body MiniProfiler will suppress compression by setting
370
+ `identity` encoding in `Accept-Encoding` request header.
374
371
 
375
372
  ## Special query strings
376
373
 
@@ -207,8 +207,7 @@
207
207
  top: 0px; }
208
208
  .profiler-results.profiler-top.profiler-left {
209
209
  left: 0px; }
210
- .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-totals,
211
- .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-result:last-child .profiler-button,
210
+ .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-left.profiler-no-controls .profiler-result:last-child .profiler-button,
212
211
  .profiler-results.profiler-top.profiler-left .profiler-controls {
213
212
  -webkit-border-bottom-right-radius: 10px;
214
213
  -moz-border-radius-bottomright: 10px;
@@ -218,8 +217,7 @@
218
217
  border-right: 1px solid #888; }
219
218
  .profiler-results.profiler-top.profiler-right {
220
219
  right: 0px; }
221
- .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-totals,
222
- .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-result:last-child .profiler-button,
220
+ .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-top.profiler-right.profiler-no-controls .profiler-result:last-child .profiler-button,
223
221
  .profiler-results.profiler-top.profiler-right .profiler-controls {
224
222
  -webkit-border-bottom-left-radius: 10px;
225
223
  -moz-border-radius-bottomleft: 10px;
@@ -231,8 +229,7 @@
231
229
  bottom: 0px; }
232
230
  .profiler-results.profiler-bottom.profiler-left {
233
231
  left: 0px; }
234
- .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-totals,
235
- .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-result:first-child .profiler-button,
232
+ .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-left.profiler-no-controls .profiler-result:first-child .profiler-button,
236
233
  .profiler-results.profiler-bottom.profiler-left .profiler-controls {
237
234
  -webkit-border-top-right-radius: 10px;
238
235
  -moz-border-radius-topright: 10px;
@@ -242,8 +239,7 @@
242
239
  border-right: 1px solid #888; }
243
240
  .profiler-results.profiler-bottom.profiler-right {
244
241
  right: 0px; }
245
- .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-totals,
246
- .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-result:first-child .profiler-button,
242
+ .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-totals, .profiler-results.profiler-bottom.profiler-right.profiler-no-controls .profiler-result:first-child .profiler-button,
247
243
  .profiler-results.profiler-bottom.profiler-right .profiler-controls {
248
244
  -webkit-border-bottom-top-radius: 10px;
249
245
  -moz-border-radius-topleft: 10px;
@@ -349,7 +345,6 @@
349
345
  @media print {
350
346
  .profiler-results {
351
347
  display: none; } }
352
-
353
348
  .profiler-queries-bg {
354
349
  z-index: 2147483642;
355
350
  display: none;
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Rack
3
3
  class MiniProfiler
4
- ASSET_VERSION = '22e813e9a683ebee90a5afa948cffb0b'
4
+ ASSET_VERSION = '015eebd28435014a417b0b8cf057054d'
5
5
  end
6
6
  end
@@ -308,6 +308,15 @@ module Rack
308
308
  status, headers, body = @app.call(env)
309
309
  end
310
310
  end
311
+ elsif path == '/rack-mini-profiler/requests'
312
+ blank_page_html = <<~HTML
313
+ <html>
314
+ <head></head>
315
+ <body></body>
316
+ </html>
317
+ HTML
318
+
319
+ status, headers, body = [200, { 'Content-Type' => 'text/html' }, [blank_page_html.dup]]
311
320
  else
312
321
  status, headers, body = @app.call(env)
313
322
  end
@@ -364,17 +373,6 @@ module Rack
364
373
  return client_settings.handle_cookie(self.flamegraph(flamegraph))
365
374
  end
366
375
 
367
- if path == '/rack-mini-profiler/requests'
368
- blank_page_html = <<~HTML
369
- <html>
370
- <head></head>
371
- <body></body>
372
- </html>
373
- HTML
374
-
375
- status, headers, body = [200, { 'Content-Type' => 'text/html' }, [blank_page_html.dup]]
376
- end
377
-
378
376
  begin
379
377
  @storage.save(page_struct)
380
378
  # no matter what it is, it should be unviewed, otherwise we will miss POST
@@ -33,7 +33,7 @@ module Rack
33
33
 
34
34
  def set_unviewed(user, id)
35
35
  key = user_key(user)
36
- if redis.exists(prefixed_id(id))
36
+ if redis.call([:exists, prefixed_id(id)]) == 1
37
37
  expire_at = Process.clock_gettime(Process::CLOCK_MONOTONIC).to_i + redis.ttl(prefixed_id(id))
38
38
  redis.zadd(key, expire_at, id)
39
39
  end
@@ -44,7 +44,7 @@ module Rack
44
44
  key = user_key(user)
45
45
  redis.del(key)
46
46
  ids.each do |id|
47
- if redis.exists(prefixed_id(id))
47
+ if redis.call([:exists, prefixed_id(id)]) == 1
48
48
  expire_at = Process.clock_gettime(Process::CLOCK_MONOTONIC).to_i + redis.ttl(prefixed_id(id))
49
49
  redis.zadd(key, expire_at, id)
50
50
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class MiniProfiler
5
- VERSION = '2.0.2'
5
+ VERSION = '2.0.3'
6
6
  end
7
7
  end
@@ -30,6 +30,8 @@ module Rack::MiniProfilerRails
30
30
 
31
31
  if serves_static_assets?(app)
32
32
  c.skip_paths << app.config.assets.prefix
33
+ wp_assets_path = get_webpacker_assets_path()
34
+ c.skip_paths << wp_assets_path if wp_assets_path
33
35
  end
34
36
 
35
37
  unless Rails.env.development? || Rails.env.test?
@@ -51,5 +51,11 @@ module Rack::MiniProfilerRailsMethods
51
51
  child[start] + child[duration] <= node[start] + node[duration]
52
52
  end
53
53
 
54
+ def get_webpacker_assets_path
55
+ if defined?(Webpacker)
56
+ Webpacker.config.public_output_path.to_s.gsub(Webpacker.config.public_path.to_s, "")
57
+ end
58
+ end
59
+
54
60
  extend self
55
61
  end
@@ -2,15 +2,25 @@
2
2
 
3
3
  if (defined?(Net) && defined?(Net::HTTP))
4
4
 
5
- Net::HTTP.class_eval do
6
- def request_with_mini_profiler(*args, &block)
7
- request = args[0]
8
- Rack::MiniProfiler.step("Net::HTTP #{request.method} #{request.path}") do
9
- request_without_mini_profiler(*args, &block)
5
+ if defined?(Rack::MINI_PROFILER_PREPEND_NET_HTTP_PATCH)
6
+ module NetHTTPWithMiniProfiler
7
+ def request(request, *args, &block)
8
+ Rack::MiniProfiler.step("Net::HTTP #{request.method} #{request.path}") do
9
+ super
10
+ end
10
11
  end
11
12
  end
12
- alias request_without_mini_profiler request
13
- alias request request_with_mini_profiler
13
+ Net::HTTP.prepend(NetHTTPWithMiniProfiler)
14
+ else
15
+ Net::HTTP.class_eval do
16
+ def request_with_mini_profiler(*args, &block)
17
+ request = args[0]
18
+ Rack::MiniProfiler.step("Net::HTTP #{request.method} #{request.path}") do
19
+ request_without_mini_profiler(*args, &block)
20
+ end
21
+ end
22
+ alias request_without_mini_profiler request
23
+ alias request request_with_mini_profiler
24
+ end
14
25
  end
15
-
16
26
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rack
4
+ MINI_PROFILER_PREPEND_NET_HTTP_PATCH = true
5
+ end
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  "CHANGELOG.md"
22
22
  ]
23
23
  s.add_runtime_dependency 'rack', '>= 1.2.0'
24
- s.required_ruby_version = '>= 2.3.0'
24
+ s.required_ruby_version = '>= 2.4.0'
25
25
 
26
26
  s.metadata = {
27
27
  'source_code_uri' => 'https://github.com/MiniProfiler/rack-mini-profiler',
@@ -30,7 +30,6 @@ Gem::Specification.new do |s|
30
30
 
31
31
  s.add_development_dependency 'rake', '< 11'
32
32
  s.add_development_dependency 'rack-test'
33
- s.add_development_dependency 'activerecord', '~> 3.0'
34
33
  s.add_development_dependency 'dalli'
35
34
  s.add_development_dependency 'rspec', '~> 3.6.0'
36
35
  s.add_development_dependency 'redis'
@@ -41,6 +40,8 @@ Gem::Specification.new do |s|
41
40
  s.add_development_dependency 'nokogiri'
42
41
  s.add_development_dependency 'rubocop-discourse'
43
42
  s.add_development_dependency 'listen'
43
+ s.add_development_dependency 'webpacker', '~> 5.1'
44
+ s.add_development_dependency 'rails', '~> 5.1'
44
45
 
45
46
  s.require_paths = ["lib"]
46
47
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-mini-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  - Robin Ward
9
9
  - Aleks Totic
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-05-25 00:00:00.000000000 Z
13
+ date: 2020-07-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -54,20 +54,6 @@ dependencies:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
- - !ruby/object:Gem::Dependency
58
- name: activerecord
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '3.0'
64
- type: :development
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - "~>"
69
- - !ruby/object:Gem::Version
70
- version: '3.0'
71
57
  - !ruby/object:Gem::Dependency
72
58
  name: dalli
73
59
  requirement: !ruby/object:Gem::Requirement
@@ -208,6 +194,34 @@ dependencies:
208
194
  - - ">="
209
195
  - !ruby/object:Gem::Version
210
196
  version: '0'
197
+ - !ruby/object:Gem::Dependency
198
+ name: webpacker
199
+ requirement: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - "~>"
202
+ - !ruby/object:Gem::Version
203
+ version: '5.1'
204
+ type: :development
205
+ prerelease: false
206
+ version_requirements: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - "~>"
209
+ - !ruby/object:Gem::Version
210
+ version: '5.1'
211
+ - !ruby/object:Gem::Dependency
212
+ name: rails
213
+ requirement: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - "~>"
216
+ - !ruby/object:Gem::Version
217
+ version: '5.1'
218
+ type: :development
219
+ prerelease: false
220
+ version_requirements: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - "~>"
223
+ - !ruby/object:Gem::Version
224
+ version: '5.1'
211
225
  description: Profiling toolkit for Rack applications with Rails integration. Client
212
226
  Side profiling, DB profiling and Server profiling.
213
227
  email: sam.saffron@gmail.com
@@ -267,6 +281,7 @@ files:
267
281
  - lib/patches/db/sequel.rb
268
282
  - lib/patches/net_patches.rb
269
283
  - lib/patches/sql_patches.rb
284
+ - lib/prepend_net_http_patch.rb
270
285
  - lib/rack-mini-profiler.rb
271
286
  - rack-mini-profiler.gemspec
272
287
  homepage: https://miniprofiler.com
@@ -275,7 +290,7 @@ licenses:
275
290
  metadata:
276
291
  source_code_uri: https://github.com/MiniProfiler/rack-mini-profiler
277
292
  changelog_uri: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/CHANGELOG.md
278
- post_install_message:
293
+ post_install_message:
279
294
  rdoc_options: []
280
295
  require_paths:
281
296
  - lib
@@ -283,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
283
298
  requirements:
284
299
  - - ">="
285
300
  - !ruby/object:Gem::Version
286
- version: 2.3.0
301
+ version: 2.4.0
287
302
  required_rubygems_version: !ruby/object:Gem::Requirement
288
303
  requirements:
289
304
  - - ">="
@@ -291,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
306
  version: '0'
292
307
  requirements: []
293
308
  rubygems_version: 3.0.3
294
- signing_key:
309
+ signing_key:
295
310
  specification_version: 4
296
311
  summary: Profiles loading speed for rack applications.
297
312
  test_files: []