prosopite 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/Gemfile.lock +97 -48
- data/README.md +14 -7
- data/lib/prosopite/middleware/rack.rb +4 -1
- data/lib/prosopite/version.rb +1 -1
- data/lib/prosopite.rb +7 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fac117d558ad73ba2057f45ce8ec278898d8c1b00aec41ec9a169f76c842c02
|
4
|
+
data.tar.gz: ee3a372e02cb138bdbaf1770b5758693c51bdedc173ff2ca93aed20413b22245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e49619ff0354d91b0ebade2c418ef5a2d189d68ed3f259dca8674e378366d441144a71c0ff1d615baa834c8a00d1aea60ac7be6435fdb1035da63a61fefc3731
|
7
|
+
data.tar.gz: a6ca678e0052bdc3cdbce19e95c88ca233162bfe45a18f87f70f2ad77e68e2c0264e18e517979356159be90ac22f103f8c4779cd5fa29766a55d72228e5e1d09
|
data/.github/workflows/ci.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,87 +1,136 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
prosopite (
|
4
|
+
prosopite (2.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actionpack (
|
10
|
-
actionview (=
|
11
|
-
activesupport (=
|
12
|
-
|
9
|
+
actionpack (8.0.1)
|
10
|
+
actionview (= 8.0.1)
|
11
|
+
activesupport (= 8.0.1)
|
12
|
+
nokogiri (>= 1.8.5)
|
13
|
+
rack (>= 2.2.4)
|
14
|
+
rack-session (>= 1.0.1)
|
13
15
|
rack-test (>= 0.6.3)
|
14
|
-
rails-dom-testing (~> 2.
|
15
|
-
rails-html-sanitizer (~> 1.
|
16
|
-
|
17
|
-
|
16
|
+
rails-dom-testing (~> 2.2)
|
17
|
+
rails-html-sanitizer (~> 1.6)
|
18
|
+
useragent (~> 0.16)
|
19
|
+
actionview (8.0.1)
|
20
|
+
activesupport (= 8.0.1)
|
18
21
|
builder (~> 3.1)
|
19
|
-
erubi (~> 1.
|
20
|
-
rails-dom-testing (~> 2.
|
21
|
-
rails-html-sanitizer (~> 1.
|
22
|
-
activemodel (
|
23
|
-
activesupport (=
|
24
|
-
activerecord (
|
25
|
-
activemodel (=
|
26
|
-
activesupport (=
|
27
|
-
|
28
|
-
|
22
|
+
erubi (~> 1.11)
|
23
|
+
rails-dom-testing (~> 2.2)
|
24
|
+
rails-html-sanitizer (~> 1.6)
|
25
|
+
activemodel (8.0.1)
|
26
|
+
activesupport (= 8.0.1)
|
27
|
+
activerecord (8.0.1)
|
28
|
+
activemodel (= 8.0.1)
|
29
|
+
activesupport (= 8.0.1)
|
30
|
+
timeout (>= 0.4.0)
|
31
|
+
activesupport (8.0.1)
|
32
|
+
base64
|
33
|
+
benchmark (>= 0.3)
|
34
|
+
bigdecimal
|
35
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
36
|
+
connection_pool (>= 2.2.5)
|
37
|
+
drb
|
29
38
|
i18n (>= 1.6, < 2)
|
39
|
+
logger (>= 1.4.2)
|
30
40
|
minitest (>= 5.1)
|
31
|
-
|
32
|
-
|
41
|
+
securerandom (>= 0.3)
|
42
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
43
|
+
uri (>= 0.13.1)
|
33
44
|
ansi (1.5.0)
|
45
|
+
base64 (0.2.0)
|
46
|
+
benchmark (0.4.0)
|
47
|
+
bigdecimal (3.1.9)
|
34
48
|
builder (3.2.4)
|
35
49
|
coderay (1.1.3)
|
36
|
-
concurrent-ruby (1.
|
50
|
+
concurrent-ruby (1.3.5)
|
51
|
+
connection_pool (2.5.0)
|
37
52
|
crass (1.0.6)
|
53
|
+
date (3.4.1)
|
54
|
+
drb (2.2.1)
|
38
55
|
erubi (1.12.0)
|
39
|
-
factory_bot (6.1
|
40
|
-
activesupport (>=
|
56
|
+
factory_bot (6.5.1)
|
57
|
+
activesupport (>= 6.1.0)
|
41
58
|
i18n (1.8.9)
|
42
59
|
concurrent-ruby (~> 1.0)
|
43
|
-
|
60
|
+
io-console (0.8.0)
|
61
|
+
irb (1.15.1)
|
62
|
+
pp (>= 0.6.0)
|
63
|
+
rdoc (>= 4.0.0)
|
64
|
+
reline (>= 0.4.2)
|
65
|
+
logger (1.6.6)
|
66
|
+
loofah (2.24.0)
|
44
67
|
crass (~> 1.0.2)
|
45
|
-
nokogiri (>= 1.
|
68
|
+
nokogiri (>= 1.12.0)
|
46
69
|
method_source (1.0.0)
|
47
|
-
mini_portile2 (2.8.
|
48
|
-
minitest (5.
|
70
|
+
mini_portile2 (2.8.8)
|
71
|
+
minitest (5.25.4)
|
49
72
|
minitest-reporters (1.5.0)
|
50
73
|
ansi
|
51
74
|
builder
|
52
75
|
minitest (>= 5.0)
|
53
76
|
ruby-progressbar
|
54
|
-
nokogiri (1.
|
55
|
-
mini_portile2 (~> 2.8.
|
77
|
+
nokogiri (1.18.3)
|
78
|
+
mini_portile2 (~> 2.8.2)
|
56
79
|
racc (~> 1.4)
|
57
|
-
nokogiri (1.
|
80
|
+
nokogiri (1.18.3-x86_64-linux-gnu)
|
58
81
|
racc (~> 1.4)
|
59
82
|
pg_query (1.3.0)
|
83
|
+
pp (0.6.2)
|
84
|
+
prettyprint
|
85
|
+
prettyprint (0.2.0)
|
60
86
|
pry (0.14.0)
|
61
87
|
coderay (~> 1.1)
|
62
88
|
method_source (~> 1.0)
|
63
|
-
|
64
|
-
|
89
|
+
psych (5.2.3)
|
90
|
+
date
|
91
|
+
stringio
|
92
|
+
racc (1.8.1)
|
93
|
+
rack (3.1.10)
|
94
|
+
rack-session (2.1.0)
|
95
|
+
base64 (>= 0.1.0)
|
96
|
+
rack (>= 3.0.0)
|
65
97
|
rack-test (2.0.2)
|
66
98
|
rack (>= 1.3)
|
67
|
-
|
68
|
-
|
99
|
+
rackup (2.2.1)
|
100
|
+
rack (>= 3)
|
101
|
+
rails-dom-testing (2.2.0)
|
102
|
+
activesupport (>= 5.0.0)
|
103
|
+
minitest
|
69
104
|
nokogiri (>= 1.6)
|
70
|
-
rails-html-sanitizer (1.
|
71
|
-
loofah (~> 2.
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
105
|
+
rails-html-sanitizer (1.6.2)
|
106
|
+
loofah (~> 2.21)
|
107
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
108
|
+
railties (8.0.1)
|
109
|
+
actionpack (= 8.0.1)
|
110
|
+
activesupport (= 8.0.1)
|
111
|
+
irb (~> 1.13)
|
112
|
+
rackup (>= 1.0.0)
|
113
|
+
rake (>= 12.2)
|
114
|
+
thor (~> 1.0, >= 1.2.2)
|
115
|
+
zeitwerk (~> 2.6)
|
78
116
|
rake (13.0.6)
|
117
|
+
rdoc (6.12.0)
|
118
|
+
psych (>= 4.0.0)
|
119
|
+
reline (0.6.0)
|
120
|
+
io-console (~> 0.5)
|
79
121
|
ruby-progressbar (1.11.0)
|
80
|
-
|
81
|
-
|
82
|
-
|
122
|
+
securerandom (0.4.1)
|
123
|
+
sqlite3 (2.5.0)
|
124
|
+
mini_portile2 (~> 2.8.0)
|
125
|
+
sqlite3 (2.5.0-x86_64-linux-gnu)
|
126
|
+
stringio (3.1.4)
|
127
|
+
thor (1.3.2)
|
128
|
+
timeout (0.4.3)
|
129
|
+
tzinfo (2.0.6)
|
83
130
|
concurrent-ruby (~> 1.0)
|
84
|
-
|
131
|
+
uri (1.0.2)
|
132
|
+
useragent (0.16.11)
|
133
|
+
zeitwerk (2.7.2)
|
85
134
|
|
86
135
|
PLATFORMS
|
87
136
|
ruby
|
@@ -100,4 +149,4 @@ DEPENDENCIES
|
|
100
149
|
sqlite3
|
101
150
|
|
102
151
|
BUNDLED WITH
|
103
|
-
2.
|
152
|
+
2.6.5
|
data/README.md
CHANGED
@@ -116,12 +116,12 @@ Or install it yourself as:
|
|
116
116
|
The preferred type of notifications can be configured with:
|
117
117
|
|
118
118
|
* `Prosopite.min_n_queries`: Minimum number of N queries to report per N+1 case. Defaults to 2.
|
119
|
-
* `Prosopite.raise = true`: Raise warnings as exceptions
|
120
|
-
* `Prosopite.rails_logger = true`: Send warnings to the Rails log
|
121
|
-
* `Prosopite.prosopite_logger = true`: Send warnings to `log/prosopite.log`
|
122
|
-
* `Prosopite.stderr_logger = true`: Send warnings to STDERR
|
119
|
+
* `Prosopite.raise = true`: Raise warnings as exceptions. Defaults to `false`.
|
120
|
+
* `Prosopite.rails_logger = true`: Send warnings to the Rails log. Defaults to `false`.
|
121
|
+
* `Prosopite.prosopite_logger = true`: Send warnings to `log/prosopite.log`. Defaults to `false`.
|
122
|
+
* `Prosopite.stderr_logger = true`: Send warnings to STDERR. Defaults to `false`.
|
123
123
|
* `Prosopite.backtrace_cleaner = my_custom_backtrace_cleaner`: use a different [ActiveSupport::BacktraceCleaner](https://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html). Defaults to `Rails.backtrace_cleaner`.
|
124
|
-
* `Prosopite.custom_logger = my_custom_logger`:
|
124
|
+
* `Prosopite.custom_logger = my_custom_logger`: Set a custom logger. See the following section for the details. Defaults to `false`.
|
125
125
|
* `Prosopite.enabled = true`: Enables or disables the gem. Defaults to `true`.
|
126
126
|
|
127
127
|
### Custom Logging Configuration
|
@@ -221,12 +221,12 @@ end
|
|
221
221
|
```
|
222
222
|
|
223
223
|
### Sidekiq
|
224
|
-
We also provide a middleware for sidekiq so that you can auto detect n+1 queries that may occur in a sidekiq job.
|
224
|
+
We also provide a middleware for sidekiq `6.5.0+` so that you can auto detect n+1 queries that may occur in a sidekiq job.
|
225
225
|
You just need to add the following to your sidekiq initializer.
|
226
226
|
|
227
227
|
```ruby
|
228
228
|
Sidekiq.configure_server do |config|
|
229
|
-
unless Rails.production?
|
229
|
+
unless Rails.env.production?
|
230
230
|
config.server_middleware do |chain|
|
231
231
|
require 'prosopite/middleware/sidekiq'
|
232
232
|
chain.add(Prosopite::Middleware::Sidekiq)
|
@@ -235,6 +235,13 @@ Sidekiq.configure_server do |config|
|
|
235
235
|
end
|
236
236
|
```
|
237
237
|
|
238
|
+
For applications running sidekiq < `6.5.0` but want to add the snippet, you can guard the snippet with something like this and remove it once you upgrade sidekiq:
|
239
|
+
```ruby
|
240
|
+
if Sidekiq::VERSION >= '6.5.0' && (Rails.env.development? || Rails.env.test?)
|
241
|
+
.....
|
242
|
+
end
|
243
|
+
```
|
244
|
+
|
238
245
|
## Allow list
|
239
246
|
|
240
247
|
Ignore notifications for call stacks containing one or more substrings / regex:
|
data/lib/prosopite/version.rb
CHANGED
data/lib/prosopite.rb
CHANGED
@@ -144,7 +144,12 @@ module Prosopite
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def fingerprint(query)
|
147
|
-
|
147
|
+
conn = if ActiveRecord::Base.respond_to?(:lease_connection)
|
148
|
+
ActiveRecord::Base.lease_connection
|
149
|
+
else
|
150
|
+
ActiveRecord::Base.connection
|
151
|
+
end
|
152
|
+
db_adapter = conn.adapter_name.downcase
|
148
153
|
if db_adapter.include?('mysql') || db_adapter.include?('trilogy')
|
149
154
|
mysql_fingerprint(query)
|
150
155
|
else
|
@@ -214,7 +219,7 @@ module Prosopite
|
|
214
219
|
@prosopite_logger ||= false
|
215
220
|
@raise ||= false
|
216
221
|
|
217
|
-
notifications_str = ''
|
222
|
+
notifications_str = String.new('')
|
218
223
|
|
219
224
|
tc[:prosopite_notifications].each do |queries, kaller|
|
220
225
|
notifications_str << "N+1 queries detected:\n"
|
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:
|
4
|
+
version: 2.0.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: 2025-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
151
|
+
rubygems_version: 3.5.3
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: N+1 auto-detection for Rails with zero false positives / false negatives
|