exception_hunter 0.3.0 → 0.4.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/README.md +5 -1
- data/lib/exception_hunter.rb +0 -1
- data/lib/exception_hunter/engine.rb +5 -0
- data/lib/exception_hunter/middleware/delayed_job_hunter.rb +69 -0
- data/lib/exception_hunter/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fb03df52c56c0849ab0400679af9ce9a7711c0eab80c42f4d79f59ff3613ace
|
4
|
+
data.tar.gz: 181ba4a3cfb249ac1a02f7ec55548f4d306ee4eb902cace8ef741d271aed394b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4379274f01ea33abbc12e696c137cfbd8fac013a052f2d34bfe86db804904bfbf1008a6d43b88c5b3768ddfd3373b56dc23b05739c21ae66c0233e861f6ce888
|
7
|
+
data.tar.gz: 60213532b0048da8de7b00383e8bf049f3a82143765add61099a8cf7f005ad1474970e4cbbc8415701b2efa2bf4a3095c60e52050a62bcedbe30742bc124ce81
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# ExceptionHunter
|
2
2
|
|
3
|
+

|
4
|
+
[](https://codeclimate.com/github/rootstrap/exception_hunter/maintainability)
|
5
|
+
[](https://codeclimate.com/github/rootstrap/exception_hunter/test_coverage)
|
6
|
+
|
3
7
|

|
4
8
|
|
5
9
|
Exception Hunter is a Rails engine meant to track errors in your Rails project. It works
|
@@ -21,7 +25,7 @@ project, and MVP or something else.
|
|
21
25
|
Add Exception Hunter to your application's Gemfile:
|
22
26
|
|
23
27
|
```ruby
|
24
|
-
gem 'exception_hunter', '~> 0.
|
28
|
+
gem 'exception_hunter', '~> 0.4.0'
|
25
29
|
```
|
26
30
|
|
27
31
|
You may also need to add [Devise](https://github.com/heartcombo/devise) to your Gemfile
|
data/lib/exception_hunter.rb
CHANGED
@@ -2,7 +2,6 @@ require 'pagy'
|
|
2
2
|
|
3
3
|
require 'exception_hunter/engine'
|
4
4
|
require 'exception_hunter/middleware/request_hunter'
|
5
|
-
require 'exception_hunter/middleware/sidekiq_hunter' if defined?(Sidekiq)
|
6
5
|
require 'exception_hunter/config'
|
7
6
|
require 'exception_hunter/error_creator'
|
8
7
|
require 'exception_hunter/error_reaper'
|
@@ -12,5 +12,10 @@ module ExceptionHunter
|
|
12
12
|
app.config.assets.precompile << 'exception_hunter/application.css'
|
13
13
|
app.config.assets.precompile << 'exception_hunter/logo.png'
|
14
14
|
end
|
15
|
+
|
16
|
+
initializer 'exception_hunter.load_middleware', group: :all do
|
17
|
+
require 'exception_hunter/middleware/sidekiq_hunter' if defined?(Sidekiq)
|
18
|
+
require 'exception_hunter/middleware/delayed_job_hunter' if defined?(Delayed)
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'delayed_job'
|
2
|
+
|
3
|
+
module ExceptionHunter
|
4
|
+
module Middleware
|
5
|
+
class DelayedJobHunter < ::Delayed::Plugin
|
6
|
+
TRACK_AT_RETRY = [0, 3, 6, 10].freeze
|
7
|
+
JOB_TRACKED_DATA = %w[
|
8
|
+
attempts
|
9
|
+
].freeze
|
10
|
+
ARGS_TRACKED_DATA = %w[
|
11
|
+
queue_name
|
12
|
+
job_class
|
13
|
+
job_id
|
14
|
+
arguments
|
15
|
+
enqueued_at
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
callbacks do |lifecycle|
|
19
|
+
lifecycle.around(:invoke_job) do |job, *args, &block|
|
20
|
+
block.call(job, *args)
|
21
|
+
|
22
|
+
rescue Exception => exception # rubocop:disable Lint/RescueException
|
23
|
+
track_exception(exception, job)
|
24
|
+
|
25
|
+
raise exception
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.track_exception(exception, job)
|
30
|
+
return unless should_track?(job.attempts)
|
31
|
+
|
32
|
+
ErrorCreator.call(
|
33
|
+
tag: ErrorCreator::WORKER_TAG,
|
34
|
+
class_name: exception.class.to_s,
|
35
|
+
message: exception.message,
|
36
|
+
environment_data: environment_data(job),
|
37
|
+
backtrace: exception.backtrace
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.environment_data(job)
|
42
|
+
job_data =
|
43
|
+
JOB_TRACKED_DATA.each_with_object({}) do |data_param, dict|
|
44
|
+
dict.merge(data_param => job.try(data_param))
|
45
|
+
end
|
46
|
+
|
47
|
+
job_class = if job.payload_object.class.name == 'ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper'
|
48
|
+
# support for Rails 4.2 ActiveJob
|
49
|
+
job.payload_object.job_data['job_class']
|
50
|
+
elsif job.payload_object.object.is_a?(Class)
|
51
|
+
job.payload_object.object.name
|
52
|
+
else
|
53
|
+
job.payload_object.object.class.name
|
54
|
+
end
|
55
|
+
args_data = (job.payload_object.try(:job_data) || {}).select { |key, _value| ARGS_TRACKED_DATA.include?(key) }
|
56
|
+
|
57
|
+
args_data['job_class'] = job_class || job.payload_object.class.name if args_data['job_class'].nil?
|
58
|
+
|
59
|
+
job_data.merge(args_data)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.should_track?(attempts)
|
63
|
+
TRACK_AT_RETRY.include?(attempts)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
Delayed::Worker.plugins << ExceptionHunter::Middleware::DelayedJobHunter
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_hunter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Vezoli
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pagy
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '3
|
20
|
+
version: '3'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '3
|
27
|
+
version: '3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: brakeman
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,14 +115,14 @@ dependencies:
|
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.
|
118
|
+
version: 0.17.1
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
125
|
+
version: 0.17.1
|
126
126
|
description:
|
127
127
|
email:
|
128
128
|
- bruno.vezoli@rootstrap.com
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/exception_hunter/engine.rb
|
176
176
|
- lib/exception_hunter/error_creator.rb
|
177
177
|
- lib/exception_hunter/error_reaper.rb
|
178
|
+
- lib/exception_hunter/middleware/delayed_job_hunter.rb
|
178
179
|
- lib/exception_hunter/middleware/request_hunter.rb
|
179
180
|
- lib/exception_hunter/middleware/sidekiq_hunter.rb
|
180
181
|
- lib/exception_hunter/tracking.rb
|
@@ -207,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
208
|
- !ruby/object:Gem::Version
|
208
209
|
version: '0'
|
209
210
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.0.8
|
211
212
|
signing_key:
|
212
213
|
specification_version: 4
|
213
214
|
summary: Exception tracking engine
|