raygun4ruby 4.0.0.pre → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +12 -6
- data/lib/raygun/configuration.rb +7 -2
- data/lib/raygun/demo_exception.rb +1 -1
- data/lib/raygun/error_subscriber.rb +5 -1
- data/lib/raygun/sidekiq.rb +11 -1
- data/lib/raygun/version.rb +1 -1
- data/test/unit/sidekiq_failure_test.rb +80 -0
- 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: 6a0724f9d47f49615745fe91cc15eb47c033036cfa20c8bb0432c7bcc9bebb33
|
4
|
+
data.tar.gz: d5addaabbd8cac2efaf4bcd919246113f8ca5c3220dd976a51cb6f51cd1a8bb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59aba8123eb5282a7d1589a65d721579e594cd2dc5b5fdfb7e05f14b9bc711242cdeac17f907c41e67813b029658f9f03049637ce54e99c0ba22c22426720507
|
7
|
+
data.tar.gz: '0597d91a00bbe36f2d13d26f9116ddb16b792c9f30393b6d73f60714b762f7787d58eefe61dab621cab149d24c8a241018e088ac5e63d67245a31c7218b95fa1'
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
## 4.0.
|
1
|
+
## 4.0.1 (29/07/2024):
|
2
|
+
|
3
|
+
- Adds the ability to unwrap `Sidekiq::JobRetry::Handled` exceptions (or ignore them entirely) ([#185](https://github.com/MindscapeHQ/raygun4ruby/pull/185))
|
4
|
+
|
5
|
+
## 4.0.0 (20/05/2024):
|
2
6
|
|
3
7
|
- BREAKING CHANGE: Remove support for end-of-life Ruby verisons and Rails versions prior to 6.0.0
|
4
8
|
- Bug fix: Fix issue with breadcrumbs not being sent to Raygun when `send_in_background` is enabled (thanks to @jjb for the bug report)
|
data/README.md
CHANGED
@@ -12,25 +12,27 @@ And then execute:
|
|
12
12
|
|
13
13
|
$ bundle install
|
14
14
|
|
15
|
-
Or, if you're not using Bundler, install the gem directly:
|
16
|
-
|
17
|
-
$ gem install raygun4ruby
|
18
|
-
|
19
15
|
## Usage
|
20
16
|
|
21
17
|
### Rails 6+
|
22
18
|
|
19
|
+
#### Step 1
|
20
|
+
|
23
21
|
Run:
|
24
22
|
|
25
23
|
rails g raygun:install YOUR_API_KEY_HERE
|
26
24
|
|
27
25
|
You can find your API key in the [Raygun app](https://app.raygun.com/) under "Application Settings".
|
28
26
|
|
27
|
+
#### Step 2
|
28
|
+
|
29
29
|
You can then test your Raygun integration by running:
|
30
30
|
|
31
31
|
rails raygun:test
|
32
32
|
|
33
|
-
You should see an "ItWorksException" appear in your Raygun dashboard. You're ready to zap those errors! :zap:
|
33
|
+
You should see an "ItWorksException" appear in your Raygun Crash Reporting dashboard. You're ready to zap those errors! :zap:
|
34
|
+
|
35
|
+
#### Step 3 (optional)
|
34
36
|
|
35
37
|
The generator will create a file in `config/initializers` called "raygun.rb". If you need to do any further configuration or customization of Raygun, that's the place to do it!
|
36
38
|
|
@@ -292,7 +294,7 @@ To see the defaults check out [affected_user.rb](https://github.com/MindscapeHQ/
|
|
292
294
|
|
293
295
|
If you're using Rails, most authentication systems will have this method set and you should be good to go.
|
294
296
|
|
295
|
-
The count of unique affected customers will appear on the error group in
|
297
|
+
The count of unique affected customers will appear on the error group in Raygun Crash Reporting. If your customer has an `email` attribute, and that email has a Gravatar associated with that address, you will also see your customer's avatar.
|
296
298
|
|
297
299
|
If you wish to keep it anonymous, you could set this identifier to something like `SecureRandom.uuid` and store that in a cookie, like so:
|
298
300
|
|
@@ -400,6 +402,10 @@ class FailingWorker
|
|
400
402
|
end
|
401
403
|
```
|
402
404
|
|
405
|
+
##### Sidekiq Retries
|
406
|
+
|
407
|
+
By default, Raygun4Ruby will unwrap `Sidekiq::JobRetry::Handled` exceptions and report the original error via `Exception#cause`. If you would prefer not to hear about retries, you can set `config.track_retried_sidekiq_jobs` to `false` in your Raygun configuration.
|
408
|
+
|
403
409
|
### Other Configuration options
|
404
410
|
|
405
411
|
For a complete list of configuration options see the [configuration.rb](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb) file
|
data/lib/raygun/configuration.rb
CHANGED
@@ -89,6 +89,9 @@ module Raygun
|
|
89
89
|
# Should we register an error handler with [Rails' built in API](https://edgeguides.rubyonrails.org/error_reporting.html)
|
90
90
|
config_option :register_rails_error_handler
|
91
91
|
|
92
|
+
# Should we track jobs that are retried in Sidekiq (ones that raise Sidekiq::JobRetry::Handled). Set to "false" to ignore.
|
93
|
+
config_option :track_retried_sidekiq_jobs
|
94
|
+
|
92
95
|
# Exception classes to ignore by default
|
93
96
|
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
94
97
|
'ActionController::RoutingError',
|
@@ -97,7 +100,8 @@ module Raygun
|
|
97
100
|
'CGI::Session::CookieStore::TamperedWithCookie',
|
98
101
|
'ActionController::UnknownAction',
|
99
102
|
'AbstractController::ActionNotFound',
|
100
|
-
'Mongoid::Errors::DocumentNotFound'
|
103
|
+
'Mongoid::Errors::DocumentNotFound',
|
104
|
+
'Sidekiq::JobRetry::Skip']
|
101
105
|
|
102
106
|
DEFAULT_FILTER_PARAMETERS = [ :password, :card_number, :cvv ]
|
103
107
|
|
@@ -142,7 +146,8 @@ module Raygun
|
|
142
146
|
breadcrumb_level: :info,
|
143
147
|
record_raw_data: false,
|
144
148
|
send_in_background: false,
|
145
|
-
error_report_send_timeout: 10
|
149
|
+
error_report_send_timeout: 10,
|
150
|
+
track_retried_sidekiq_jobs: true
|
146
151
|
)
|
147
152
|
end
|
148
153
|
|
@@ -11,7 +11,7 @@ module Raygun
|
|
11
11
|
response = Raygun.track_exception(e)
|
12
12
|
|
13
13
|
if response.success?
|
14
|
-
puts "Success! Now go check your Raygun
|
14
|
+
puts "Success! Now go check your Raygun Crash Reporting dashboard"
|
15
15
|
else
|
16
16
|
puts "Oh-oh, something went wrong - double check your API key"
|
17
17
|
puts "API Key - " << Raygun.configuration.api_key << ")"
|
@@ -16,6 +16,10 @@ class Raygun::ErrorSubscriber
|
|
16
16
|
tags: ["rails_error_reporter", *tags].compact
|
17
17
|
}
|
18
18
|
|
19
|
-
|
19
|
+
if source == "job.sidekiq" && defined?(Sidekiq)
|
20
|
+
Raygun::SidekiqReporter.call(error, data)
|
21
|
+
else
|
22
|
+
Raygun.track_exception(error, data)
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
data/lib/raygun/sidekiq.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
module Raygun
|
7
7
|
|
8
8
|
class SidekiqReporter
|
9
|
-
def self.call(exception, context_hash, config)
|
9
|
+
def self.call(exception, context_hash = {}, config = nil)
|
10
10
|
user = affected_user(context_hash)
|
11
11
|
data = {
|
12
12
|
custom_data: {
|
@@ -14,6 +14,16 @@ module Raygun
|
|
14
14
|
},
|
15
15
|
tags: ['sidekiq']
|
16
16
|
}
|
17
|
+
|
18
|
+
if exception.is_a?(Sidekiq::JobRetry::Handled) && exception.cause
|
19
|
+
if Raygun.configuration.track_retried_sidekiq_jobs
|
20
|
+
data.merge!(sidekiq_retried: true)
|
21
|
+
exception = exception.cause
|
22
|
+
else
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
17
27
|
if exception.instance_variable_defined?(:@__raygun_correlation_id) && correlation_id = exception.instance_variable_get(:@__raygun_correlation_id)
|
18
28
|
data.merge!(correlation_id: correlation_id)
|
19
29
|
end
|
data/lib/raygun/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative "../test_helper.rb"
|
2
2
|
|
3
3
|
require "sidekiq"
|
4
|
+
|
4
5
|
# Convince Sidekiq it's on a server :)
|
5
6
|
module Sidekiq
|
6
7
|
class << self
|
@@ -15,6 +16,8 @@ require "raygun/sidekiq"
|
|
15
16
|
class SidekiqFailureTest < Raygun::UnitTest
|
16
17
|
|
17
18
|
def setup
|
19
|
+
require "sidekiq/job_retry"
|
20
|
+
|
18
21
|
super
|
19
22
|
Raygun.configuration.send_in_background = false
|
20
23
|
|
@@ -32,6 +35,61 @@ class SidekiqFailureTest < Raygun::UnitTest
|
|
32
35
|
assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
|
33
36
|
end
|
34
37
|
|
38
|
+
def test_failure_backend_unwraps_retries
|
39
|
+
WebMock.reset!
|
40
|
+
|
41
|
+
unwrapped_stub = stub_request(:post, 'https://api.raygun.com/entries').
|
42
|
+
with(body: /StandardError/).
|
43
|
+
to_return(status: 202)
|
44
|
+
|
45
|
+
begin
|
46
|
+
raise StandardError.new("Some job in Sidekiq failed, oh dear!")
|
47
|
+
rescue
|
48
|
+
raise Sidekiq::JobRetry::Handled
|
49
|
+
end
|
50
|
+
|
51
|
+
rescue Sidekiq::JobRetry::Handled => e
|
52
|
+
|
53
|
+
response = Raygun::SidekiqReporter.call(
|
54
|
+
e,
|
55
|
+
{ sidekick_name: "robin" },
|
56
|
+
{} # config
|
57
|
+
)
|
58
|
+
|
59
|
+
assert_requested unwrapped_stub
|
60
|
+
assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_failured_backend_ignores_retries_if_configured
|
64
|
+
Raygun.configuration.track_retried_sidekiq_jobs = false
|
65
|
+
|
66
|
+
begin
|
67
|
+
raise StandardError.new("Some job in Sidekiq failed, oh dear!")
|
68
|
+
rescue
|
69
|
+
raise Sidekiq::JobRetry::Handled
|
70
|
+
end
|
71
|
+
|
72
|
+
rescue Sidekiq::JobRetry::Handled => e
|
73
|
+
|
74
|
+
refute Raygun::SidekiqReporter.call(e,
|
75
|
+
{ sidekick_name: "robin" },
|
76
|
+
{} # config
|
77
|
+
)
|
78
|
+
ensure
|
79
|
+
Raygun.configuration.track_retried_sidekiq_jobs = true
|
80
|
+
end
|
81
|
+
|
82
|
+
# See https://github.com/MindscapeHQ/raygun4ruby/issues/183
|
83
|
+
# (This is how Sidekiq pre 7.1.5 calls error handlers: https://github.com/sidekiq/sidekiq/blob/1ba89bbb22d2fd574b11702d8b6ed63ae59e2256/lib/sidekiq/config.rb#L269)
|
84
|
+
def test_failure_backend_appears_to_work_without_config_argument
|
85
|
+
response = Raygun::SidekiqReporter.call(
|
86
|
+
StandardError.new("Oh no! Your Sidekiq has failed!"),
|
87
|
+
{ sidekick_name: "robin" }
|
88
|
+
)
|
89
|
+
|
90
|
+
assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
|
91
|
+
end
|
92
|
+
|
35
93
|
def test_we_are_in_sidekiqs_list_of_error_handlers
|
36
94
|
# Sidekiq 7.x stores error handlers inside a configuration object, while 6.x and below stores them directly against the Sidekiq module
|
37
95
|
error_handlers = Sidekiq.respond_to?(:error_handlers) ? Sidekiq.error_handlers : Sidekiq.default_configuration.error_handlers
|
@@ -39,4 +97,26 @@ class SidekiqFailureTest < Raygun::UnitTest
|
|
39
97
|
assert error_handlers.include?(Raygun::SidekiqReporter)
|
40
98
|
end
|
41
99
|
|
100
|
+
def test_rails_error_reporter_uses_sidekiq_reporter
|
101
|
+
WebMock.reset!
|
102
|
+
|
103
|
+
tagged_request = stub_request(:post, 'https://api.raygun.com/entries').
|
104
|
+
with(body: /"sidekiq"/). # should have a sidekiq tag!
|
105
|
+
to_return(status: 202)
|
106
|
+
|
107
|
+
error = StandardError.new("Oh no! Your Sidekiq has failed!")
|
108
|
+
|
109
|
+
response = Raygun::ErrorSubscriber.new.report(
|
110
|
+
error,
|
111
|
+
handled: true,
|
112
|
+
severity: "error",
|
113
|
+
context: { sidekick_name: "robin" },
|
114
|
+
source: "job.sidekiq"
|
115
|
+
)
|
116
|
+
|
117
|
+
assert response && response.success?, "Expected success, got #{response.class}: #{response.inspect}"
|
118
|
+
|
119
|
+
assert_requested tagged_request
|
120
|
+
end
|
121
|
+
|
42
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindscape
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|