sentry-delayed_job 4.2.1 → 4.5.0.pre.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.craft.yml +2 -2
- data/CHANGELOG.md +31 -0
- data/lib/sentry-delayed_job.rb +1 -0
- data/lib/sentry/delayed_job/configuration.rb +21 -0
- data/lib/sentry/delayed_job/plugin.rb +38 -16
- data/lib/sentry/delayed_job/version.rb +1 -1
- data/sentry-delayed_job.gemspec +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: e71b41fbb9ead2dfb1755bed7a0f2bf1ac245d0e7348776552d10640b98ccd9e
|
4
|
+
data.tar.gz: 180c9b9da92a94126a8dadd41c2a5e11e74784f2d297200f938b23c55c7498ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f9a362698b4bed0d3fcd01eeec6144c1cba52288a0aadf219c63d3dc0696c308f15405a72a45d2d10735351f512e1caf9b176baba73db8ea21515bc26463eff
|
7
|
+
data.tar.gz: f98684f3377e74102d7f49e8fd4726b02ca56a153a3130e259c40eafdb108fad4efd0f1ddc3224456cf055b6a277db58d90862934a83c302745823b318ae1538
|
data/.craft.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.4.0
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- Allow delayed job's exceptions to be reported to sentry until the last job retry [#1364](https://github.com/getsentry/sentry-ruby/pull/1364)
|
8
|
+
|
9
|
+
Add the `report_after_job_retries` configuration option to only report an exception to Sentry if this is the last job's retry after multiple exceptions.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
config.delayed_job.report_after_job_retries = true # default is false
|
13
|
+
```
|
14
|
+
|
15
|
+
- Use context for delayed_job's job info [#1395](https://github.com/getsentry/sentry-ruby/pull/1395)
|
16
|
+
|
17
|
+
**Before:**
|
18
|
+
|
19
|
+
<img width="60%" alt="job info in extra" src="https://user-images.githubusercontent.com/5079556/114307133-de856c00-9b10-11eb-8967-cd0e67e80539.png">
|
20
|
+
|
21
|
+
**After:**
|
22
|
+
|
23
|
+
<img width="60%" alt="job info in context" src="https://user-images.githubusercontent.com/5079556/114307135-e2b18980-9b10-11eb-9fc4-af885bf0f68d.png">
|
24
|
+
|
25
|
+
## 4.3.1
|
26
|
+
|
27
|
+
- Return delayed job when the SDK is not initialized [#1373](https://github.com/getsentry/sentry-ruby/pull/1373)
|
28
|
+
- Fixes [#1334](https://github.com/getsentry/sentry-ruby/issues/1334)
|
29
|
+
|
30
|
+
## 4.3.0
|
31
|
+
|
32
|
+
- No integration-specific changes
|
33
|
+
|
3
34
|
## 4.2.1
|
4
35
|
|
5
36
|
- Use ::Rails::Railtie for checking Rails definition [#1287](https://github.com/getsentry/sentry-ruby/pull/1284)
|
data/lib/sentry-delayed_job.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sentry
|
2
|
+
class Configuration
|
3
|
+
attr_reader :delayed_job
|
4
|
+
|
5
|
+
add_post_initialization_callback do
|
6
|
+
@delayed_job = Sentry::DelayedJob::Configuration.new
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module DelayedJob
|
11
|
+
class Configuration
|
12
|
+
# Set this option to true if you want Sentry to only capture the last job
|
13
|
+
# retry if it fails.
|
14
|
+
attr_accessor :report_after_job_retries
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@report_after_job_retries = false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,16 +4,22 @@ require "delayed_job"
|
|
4
4
|
module Sentry
|
5
5
|
module DelayedJob
|
6
6
|
class Plugin < ::Delayed::Plugin
|
7
|
+
# need to symbolize strings as keyword arguments in Ruby 2.4~2.6
|
8
|
+
DELAYED_JOB_CONTEXT_KEY = :"Delayed-Job"
|
9
|
+
ACTIVE_JOB_CONTEXT_KEY = :"Active-Job"
|
10
|
+
|
7
11
|
callbacks do |lifecycle|
|
8
12
|
lifecycle.around(:invoke_job) do |job, *args, &block|
|
13
|
+
next block.call(job, *args) unless Sentry.initialized?
|
14
|
+
|
9
15
|
Sentry.with_scope do |scope|
|
10
|
-
scope.
|
16
|
+
scope.set_contexts(**generate_contexts(job))
|
11
17
|
scope.set_tags("delayed_job.queue" => job.queue, "delayed_job.id" => job.id.to_s)
|
12
18
|
|
13
19
|
begin
|
14
20
|
block.call(job, *args)
|
15
21
|
rescue Exception => e
|
16
|
-
|
22
|
+
capture_exception(e, job)
|
17
23
|
|
18
24
|
raise
|
19
25
|
end
|
@@ -21,27 +27,43 @@ module Sentry
|
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
24
|
-
def self.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
def self.generate_contexts(job)
|
31
|
+
context = {}
|
32
|
+
|
33
|
+
context[DELAYED_JOB_CONTEXT_KEY] = {
|
34
|
+
id: job.id.to_s,
|
35
|
+
priority: job.priority,
|
36
|
+
attempts: job.attempts,
|
37
|
+
run_at: job.run_at,
|
38
|
+
locked_at: job.locked_at,
|
39
|
+
locked_by: job.locked_by,
|
40
|
+
queue: job.queue,
|
41
|
+
created_at: job.created_at,
|
42
|
+
last_error: job.last_error&.byteslice(0..1000),
|
43
|
+
handler: job.handler&.byteslice(0..1000)
|
36
44
|
}
|
37
45
|
|
38
46
|
if job.payload_object.respond_to?(:job_data)
|
47
|
+
context[ACTIVE_JOB_CONTEXT_KEY] = {}
|
48
|
+
|
39
49
|
job.payload_object.job_data.each do |key, value|
|
40
|
-
|
50
|
+
context[ACTIVE_JOB_CONTEXT_KEY][key.to_sym] = value
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
44
|
-
|
54
|
+
context
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.capture_exception(exception, job)
|
58
|
+
Sentry::DelayedJob.capture_exception(exception, hint: { background: false }) if report?(job)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.report?(job)
|
62
|
+
return true unless Sentry.configuration.delayed_job.report_after_job_retries
|
63
|
+
|
64
|
+
# We use the predecessor because the job's attempts haven't been increased to the new
|
65
|
+
# count at this point.
|
66
|
+
job.attempts >= Delayed::Worker.max_attempts.pred
|
45
67
|
end
|
46
68
|
end
|
47
69
|
end
|
data/sentry-delayed_job.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-delayed_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.0.pre.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sentry-ruby-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: 4.5.0.pre.beta.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: 4.5.0.pre.beta.1
|
27
27
|
description: A gem that provides DelayedJob integration for the Sentry error logger
|
28
28
|
email: accounts@sentry.io
|
29
29
|
executables: []
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- example/Gemfile
|
48
48
|
- example/app.rb
|
49
49
|
- lib/sentry-delayed_job.rb
|
50
|
+
- lib/sentry/delayed_job/configuration.rb
|
50
51
|
- lib/sentry/delayed_job/plugin.rb
|
51
52
|
- lib/sentry/delayed_job/version.rb
|
52
53
|
- sentry-delayed_job.gemspec
|
@@ -68,11 +69,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
69
|
version: '2.4'
|
69
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
71
|
requirements:
|
71
|
-
- - "
|
72
|
+
- - ">"
|
72
73
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
74
|
+
version: 1.3.1
|
74
75
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.1.6
|
76
77
|
signing_key:
|
77
78
|
specification_version: 4
|
78
79
|
summary: A gem that provides DelayedJob integration for the Sentry error logger
|