raygun4ruby 4.0.0 → 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 +4 -0
- data/README.md +4 -0
- data/lib/raygun/configuration.rb +5 -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,3 +1,7 @@
|
|
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
|
+
|
1
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
|
data/README.md
CHANGED
@@ -402,6 +402,10 @@ class FailingWorker
|
|
402
402
|
end
|
403
403
|
```
|
404
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
|
+
|
405
409
|
### Other Configuration options
|
406
410
|
|
407
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',
|
@@ -143,7 +146,8 @@ module Raygun
|
|
143
146
|
breadcrumb_level: :info,
|
144
147
|
record_raw_data: false,
|
145
148
|
send_in_background: false,
|
146
|
-
error_report_send_timeout: 10
|
149
|
+
error_report_send_timeout: 10,
|
150
|
+
track_retried_sidekiq_jobs: true
|
147
151
|
)
|
148
152
|
end
|
149
153
|
|
@@ -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
|