prosopite 1.3.3 → 1.4.1
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/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: 9353ec80e12bf0261cfb9c02f9845c2bedfd4285770e6691a18490542c551e24
|
4
|
+
data.tar.gz: 29ad5098ea8739119a54fdbc58d241debf166b6c0453388247b9d02b007d021a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e9fe96155a0837e355c5a4292a592ecef3e71defaea97a62dc700164ea64c0647fce33975bc0ab3b79b6d09c4115c10d4c18e2bec0852f52b8a5df287ace0b
|
7
|
+
data.tar.gz: 8176697cd034b20ca5aacbae33377424a56694cd9fc3faa90cb3dce61b6815fa5bf532939d87edb919448dee098e9abe55c52fc1422b20e76545d3d1fdb56079
|
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.env.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.1
|
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-28 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
|