prosopite 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/prosopite/version.rb +1 -1
- data/lib/prosopite.rb +12 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ba705386994a5f73eb64b024eadd45fd4c29db669ccc408283746d03d58bdf8
|
|
4
|
+
data.tar.gz: b3d52ea151dd88b9da262286df321fcdafd2245ce3b09c9539fd54e9ae54ee8d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6f74f6cd59e7537429f32300072394c428837e3ec0dd8aed971d601f447c0f3b28e2bdd68f240f98906be205d23958c3cdd8cbf181821cc26f4f435de5f17c8
|
|
7
|
+
data.tar.gz: 570b9ed4965908b45b5f1f5d6dc1b41d84e0b00759c93e1ff875aa181f143c445ec910ad96dfb4c52ba2020e4948660fc203d3ff8cd8c7496bc870acf0df8180
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -329,6 +329,7 @@ class ApplicationController < ActionController::Base
|
|
|
329
329
|
end
|
|
330
330
|
end
|
|
331
331
|
```
|
|
332
|
+
|
|
332
333
|
```ruby
|
|
333
334
|
# app/controllers/books_controller.rb
|
|
334
335
|
class BooksController < ApplicationController
|
|
@@ -343,6 +344,7 @@ class BooksController < ApplicationController
|
|
|
343
344
|
@book.reviews.map(&:author) # This will not raise N+1 errors
|
|
344
345
|
end
|
|
345
346
|
end
|
|
347
|
+
```
|
|
346
348
|
|
|
347
349
|
## Custom Logging Configuration
|
|
348
350
|
|
data/lib/prosopite/version.rb
CHANGED
data/lib/prosopite.rb
CHANGED
|
@@ -51,6 +51,7 @@ module Prosopite
|
|
|
51
51
|
tc[:prosopite_query_counter] = Hash.new(0)
|
|
52
52
|
tc[:prosopite_query_holder] = Hash.new { |h, k| h[k] = [] }
|
|
53
53
|
tc[:prosopite_query_caller] = {}
|
|
54
|
+
tc[:prosopite_query_duration] = Hash.new(0.0)
|
|
54
55
|
|
|
55
56
|
@allow_stack_paths ||= []
|
|
56
57
|
@ignore_pauses ||= false
|
|
@@ -111,6 +112,7 @@ module Prosopite
|
|
|
111
112
|
tc[:prosopite_query_counter] = nil
|
|
112
113
|
tc[:prosopite_query_holder] = nil
|
|
113
114
|
tc[:prosopite_query_caller] = nil
|
|
115
|
+
tc[:prosopite_query_duration] = nil
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
def start_raise
|
|
@@ -151,8 +153,9 @@ module Prosopite
|
|
|
151
153
|
is_allowed = kaller.any? { |f| allow_list.any? { |s| f.match?(s) } }
|
|
152
154
|
|
|
153
155
|
unless is_allowed
|
|
156
|
+
duration_ms = tc[:prosopite_query_duration][location_key]
|
|
154
157
|
queries.each do |q|
|
|
155
|
-
tc[:prosopite_notifications][q] = kaller
|
|
158
|
+
tc[:prosopite_notifications][q] = { kaller: kaller, duration_ms: duration_ms }
|
|
156
159
|
end
|
|
157
160
|
end
|
|
158
161
|
end
|
|
@@ -231,8 +234,12 @@ module Prosopite
|
|
|
231
234
|
|
|
232
235
|
notifications_str = String.new('')
|
|
233
236
|
|
|
234
|
-
tc[:prosopite_notifications].each do |queries,
|
|
235
|
-
|
|
237
|
+
tc[:prosopite_notifications].each do |queries, info|
|
|
238
|
+
kaller = info[:kaller]
|
|
239
|
+
duration_ms = info[:duration_ms]
|
|
240
|
+
time_str = duration_ms ? " (#{duration_ms.round(1)}ms)" : ''
|
|
241
|
+
|
|
242
|
+
notifications_str << "N+1 queries detected#{time_str}:\n"
|
|
236
243
|
|
|
237
244
|
queries.each { |q| notifications_str << " #{q}\n" }
|
|
238
245
|
|
|
@@ -272,7 +279,7 @@ module Prosopite
|
|
|
272
279
|
@subscribed ||= false
|
|
273
280
|
return if @subscribed
|
|
274
281
|
|
|
275
|
-
ActiveSupport::Notifications.subscribe 'sql.active_record' do |_,
|
|
282
|
+
ActiveSupport::Notifications.subscribe 'sql.active_record' do |_, start, finish, _, data|
|
|
276
283
|
sql, name = data[:sql], data[:name]
|
|
277
284
|
|
|
278
285
|
if scan? && name != "SCHEMA" && sql.include?('SELECT') && data[:cached].nil? && !ignore_query?(sql)
|
|
@@ -287,6 +294,7 @@ module Prosopite
|
|
|
287
294
|
|
|
288
295
|
tc[:prosopite_query_counter][location_key] += 1
|
|
289
296
|
tc[:prosopite_query_holder][location_key] << sql
|
|
297
|
+
tc[:prosopite_query_duration][location_key] += (finish - start) * 1000 if tc[:prosopite_query_duration]
|
|
290
298
|
|
|
291
299
|
if tc[:prosopite_query_counter][location_key] > 1
|
|
292
300
|
tc[:prosopite_query_caller][location_key] = query_caller
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prosopite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mpampis Kostas
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pry
|