sentry-delayed_job 4.3.1 → 4.4.0.pre.beta.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/.craft.yml +3 -2
- data/CHANGELOG.md +22 -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 +36 -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: 50d21b952977b6c1028402322adeec2ed87a98025a042c08b220b62f5fd18669
|
4
|
+
data.tar.gz: 16c3a1160593d15ad08c214a78cc7d7afbb2030edeedc23af73900b817dbd372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56753ecc4da486738dca54acad67c87471fcd406088a27ffdaa528785b21ab5767107c69d9f2affcb9f12c3d25bbfade91f78be8f509c3e9a38bf16f7dbf2ad2
|
7
|
+
data.tar.gz: 6effc1073db4d525268ccf23cff54886f293623c506fcb670e512e0547329b62727214e20b79e181c986084328cd6d4090286f97d041bcf3eb49726649019d84
|
data/.craft.yml
CHANGED
@@ -11,9 +11,10 @@ artifactProvider:
|
|
11
11
|
name: github
|
12
12
|
targets:
|
13
13
|
- name: gem
|
14
|
-
- name: github
|
15
|
-
tagPrefix: sentry-delayed_job-v
|
16
14
|
- name: registry
|
17
15
|
type: sdk
|
18
16
|
config:
|
19
17
|
canonical: 'gem:sentry-delayed_job'
|
18
|
+
- name: github
|
19
|
+
tagPrefix: sentry-delayed_job-v
|
20
|
+
changelog: sentry-delayed_job/CHANGELOG
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.4.0-beta.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
|
+
|
3
25
|
## 4.3.1
|
4
26
|
|
5
27
|
- Return delayed job when the SDK is not initialized [#1373](https://github.com/getsentry/sentry-ruby/pull/1373)
|
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,18 +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|
|
9
13
|
next block.call(job, *args) unless Sentry.initialized?
|
10
14
|
|
11
15
|
Sentry.with_scope do |scope|
|
12
|
-
scope.
|
16
|
+
scope.set_contexts(**generate_contexts(job))
|
13
17
|
scope.set_tags("delayed_job.queue" => job.queue, "delayed_job.id" => job.id.to_s)
|
14
18
|
|
15
19
|
begin
|
16
20
|
block.call(job, *args)
|
17
21
|
rescue Exception => e
|
18
|
-
|
22
|
+
capture_exception(e, job)
|
19
23
|
|
20
24
|
raise
|
21
25
|
end
|
@@ -23,27 +27,43 @@ module Sentry
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
|
-
def self.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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)
|
38
44
|
}
|
39
45
|
|
40
46
|
if job.payload_object.respond_to?(:job_data)
|
47
|
+
context[ACTIVE_JOB_CONTEXT_KEY] = {}
|
48
|
+
|
41
49
|
job.payload_object.job_data.each do |key, value|
|
42
|
-
|
50
|
+
context[ACTIVE_JOB_CONTEXT_KEY][key.to_sym] = value
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
46
|
-
|
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
|
47
67
|
end
|
48
68
|
end
|
49
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.4.0.pre.beta.0
|
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-04-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.4.0.pre.beta
|
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.4.0.pre.beta
|
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.0.3
|
76
|
+
rubygems_version: 3.0.3.1
|
76
77
|
signing_key:
|
77
78
|
specification_version: 4
|
78
79
|
summary: A gem that provides DelayedJob integration for the Sentry error logger
|