sentry-delayed_job 4.3.1 → 4.5.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 +24 -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 +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 291ad24d5e1b725ee69e102e04a8af222266e1741f5fba72d47795a4b0122a30
|
4
|
+
data.tar.gz: ec56b89b610a7f329cf9bac7f7610ec2eddb18fbf06db71771140cca18027bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6762bc20c73322886c1ad9d1ee02387bd098bb46fb53c958193bfa2d6613572a6ac1da9d705d230f4a42765d8f7f49ed30bd190c55a97e335e62a15195eb360
|
7
|
+
data.tar.gz: da7960812e190ae7bdd8b5603823fa784a75de793743b293daef299ce78c077cbe2078b472a504be4ecb4d2454a9ce666334fcd06b5f98c6180c78c7ca460751
|
data/.craft.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
Individual gem's changelog has been deprecated. Please check the [project changelog](https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md).
|
4
|
+
|
5
|
+
## 4.4.0
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
- Allow delayed job's exceptions to be reported to sentry until the last job retry [#1364](https://github.com/getsentry/sentry-ruby/pull/1364)
|
10
|
+
|
11
|
+
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.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
config.delayed_job.report_after_job_retries = true # default is false
|
15
|
+
```
|
16
|
+
|
17
|
+
- Use context for delayed_job's job info [#1395](https://github.com/getsentry/sentry-ruby/pull/1395)
|
18
|
+
|
19
|
+
**Before:**
|
20
|
+
|
21
|
+
<img width="60%" alt="job info in extra" src="https://user-images.githubusercontent.com/5079556/114307133-de856c00-9b10-11eb-8967-cd0e67e80539.png">
|
22
|
+
|
23
|
+
**After:**
|
24
|
+
|
25
|
+
<img width="60%" alt="job info in context" src="https://user-images.githubusercontent.com/5079556/114307135-e2b18980-9b10-11eb-9fc4-af885bf0f68d.png">
|
26
|
+
|
3
27
|
## 4.3.1
|
4
28
|
|
5
29
|
- 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
@@ -16,11 +16,11 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
-
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
20
20
|
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency "sentry-ruby-core", "~> 4.
|
25
|
+
spec.add_dependency "sentry-ruby-core", "~> 4.5.0"
|
26
26
|
end
|
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.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-06-04 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
|
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
|
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
|
@@ -56,7 +57,7 @@ licenses:
|
|
56
57
|
metadata:
|
57
58
|
homepage_uri: https://github.com/getsentry/sentry-ruby
|
58
59
|
source_code_uri: https://github.com/getsentry/sentry-ruby
|
59
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/
|
60
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
|
60
61
|
post_install_message:
|
61
62
|
rdoc_options: []
|
62
63
|
require_paths:
|
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: '0'
|
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
|