prosopite 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +32 -0
- data/lib/prosopite/middleware/rack.rb +13 -0
- data/lib/prosopite/middleware/sidekiq.rb +14 -0
- data/lib/prosopite/version.rb +1 -1
- data/lib/prosopite.rb +17 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b53b2e152727ab756b2ddb8ae7b34e36c82f0bdb84a59a7345cdf3a8866daf88
|
4
|
+
data.tar.gz: b7aed1d1436d6fb14347b826eed46802ee7c0bb9069a22cdf4bf01d5ce1fbad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c42247c6d608841951aeec07580528578581856dff3f24a0bd72655036c9aace5de4db18587e2db489e6f5a44662531b45e0a2ec900da37e65d3c3e2a1c10a3e
|
7
|
+
data.tar.gz: b164c81ea349b7b537e09c286110316fe8d36b5b2343df425543786ef92f7448d6e1632d792a37146f2af77d418f9bb17a1dbe8c146af643f2c2362fe9bf99b3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -122,6 +122,7 @@ The preferred type of notifications can be configured with:
|
|
122
122
|
* `Prosopite.stderr_logger = true`: Send warnings to STDERR
|
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
124
|
* `Prosopite.custom_logger = my_custom_logger`:
|
125
|
+
* `Prosopite.enabled = true`: Enables or disables the gem. Defaults to `true`.
|
125
126
|
|
126
127
|
### Custom Logging Configuration
|
127
128
|
|
@@ -203,6 +204,37 @@ end
|
|
203
204
|
|
204
205
|
WARNING: scan/finish should run before/after **each** test and NOT before/after the whole suite.
|
205
206
|
|
207
|
+
## Middleware
|
208
|
+
|
209
|
+
### Rack
|
210
|
+
|
211
|
+
Instead of using an `around_action` hook in a Rails Controller, you can also use the rack middleware instead
|
212
|
+
implementing auto detect for all controllers.
|
213
|
+
|
214
|
+
Add the following line into your `config/initializers/prosopite.rb` file.
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
unless Rails.production?
|
218
|
+
require 'prosopite/middleware/rack'
|
219
|
+
Rails.configuration.middleware.use(Prosopite::Middleware::Rack)
|
220
|
+
end
|
221
|
+
|
222
|
+
|
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.
|
225
|
+
You just need to add the following to your sidekiq initializer.
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
Sidekiq.configure_server do |config|
|
229
|
+
unless Rails.production?
|
230
|
+
config.server_middleware do |chain|
|
231
|
+
require 'prosopite/middleware/sidekiq'
|
232
|
+
chain.add(Prosopite::Middleware::Sidekiq)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
```
|
237
|
+
|
206
238
|
## Allow list
|
207
239
|
|
208
240
|
Ignore notifications for call stacks containing one or more substrings / regex:
|
data/lib/prosopite/version.rb
CHANGED
data/lib/prosopite.rb
CHANGED
@@ -13,7 +13,8 @@ module Prosopite
|
|
13
13
|
:prosopite_logger,
|
14
14
|
:custom_logger,
|
15
15
|
:ignore_pauses,
|
16
|
-
:backtrace_cleaner
|
16
|
+
:backtrace_cleaner,
|
17
|
+
:enabled
|
17
18
|
|
18
19
|
attr_accessor :allow_stack_paths,
|
19
20
|
:ignore_queries,
|
@@ -29,9 +30,21 @@ module Prosopite
|
|
29
30
|
@backtrace_cleaner ||= Rails.backtrace_cleaner
|
30
31
|
end
|
31
32
|
|
33
|
+
def enabled?
|
34
|
+
@enabled = true if @enabled.nil?
|
35
|
+
|
36
|
+
@enabled
|
37
|
+
end
|
38
|
+
|
39
|
+
def disabled?
|
40
|
+
!enabled?
|
41
|
+
end
|
42
|
+
|
32
43
|
def scan
|
33
44
|
tc[:prosopite_scan] ||= false
|
34
|
-
|
45
|
+
if scan? || disabled?
|
46
|
+
return block_given? ? yield : nil
|
47
|
+
end
|
35
48
|
|
36
49
|
subscribe
|
37
50
|
|
@@ -131,7 +144,8 @@ module Prosopite
|
|
131
144
|
end
|
132
145
|
|
133
146
|
def fingerprint(query)
|
134
|
-
|
147
|
+
db_adapter = ActiveRecord::Base.connection.adapter_name.downcase
|
148
|
+
if db_adapter.include?('mysql') || db_adapter.include?('trilogy')
|
135
149
|
mysql_fingerprint(query)
|
136
150
|
else
|
137
151
|
begin
|
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: 1.
|
4
|
+
version: 1.4.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: 2023-
|
11
|
+
date: 2023-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -123,6 +123,8 @@ files:
|
|
123
123
|
- README.md
|
124
124
|
- Rakefile
|
125
125
|
- lib/prosopite.rb
|
126
|
+
- lib/prosopite/middleware/rack.rb
|
127
|
+
- lib/prosopite/middleware/sidekiq.rb
|
126
128
|
- lib/prosopite/version.rb
|
127
129
|
- prosopite.gemspec
|
128
130
|
homepage: https://github.com/charkost/prosopite
|