sentry-delayed_job 4.3.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31b71a6705433af7755c02ede20348408ba91a1b329a3e8fe17bdf5b9e7dab16
4
- data.tar.gz: f6375ecf44331674fe16ba55982019829d1f1499c01fdb2115d1d932554cd179
3
+ metadata.gz: 056a402ebaef3f63d8e96643e694307e20b77c480c084128248ea6adf9d4bccc
4
+ data.tar.gz: f07073033d5cbb695c6dabe5a00bef1cbba3b22fdbb0320a2dcc4977bfb34f99
5
5
  SHA512:
6
- metadata.gz: 754ddf0fcd84140eec97cd2cb742dc2241169a7367d9ad545f78a131b2c1933c6fabfdac7c54d9b9727dee80d046be2680c9630967a9d19d63605c056403f741
7
- data.tar.gz: 292573fa1e44cf7be0d0464561aa1d5f70cdca7b4cc0f2951712e845884d6f1711ef9c1af4a7312e810659060135cb4988b7d0f5e591d3d9dd451116d16cd244
6
+ metadata.gz: aa7deb183518153ca434001065cecb46d79f23e948b282ec031bf93cc61ec9c744427949f714b19ad9b0a5f5c7cc80cdb4583124efeaa1ea696fe85476865a00
7
+ data.tar.gz: 4890714298f5f9dfe5704fd441630524fb3adcf56f068243357259a136f94026b33e34a55c788bb305dff54b62a46a615043b406b1319cfa4a83e38b22e660d4
data/.craft.yml CHANGED
@@ -11,9 +11,9 @@ 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
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
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
+
27
+ ## 4.3.1
28
+
29
+ - Return delayed job when the SDK is not initialized [#1373](https://github.com/getsentry/sentry-ruby/pull/1373)
30
+ - Fixes [#1334](https://github.com/getsentry/sentry-ruby/issues/1334)
31
+
3
32
  ## 4.3.0
4
33
 
5
34
  - No integration-specific changes
@@ -1,6 +1,7 @@
1
1
  require "delayed_job"
2
2
  require "sentry-ruby"
3
3
  require "sentry/integrable"
4
+ require "sentry/delayed_job/configuration"
4
5
  require "sentry/delayed_job/version"
5
6
  require "sentry/delayed_job/plugin"
6
7
 
@@ -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.set_extras(**generate_extra(job))
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
- Sentry::DelayedJob.capture_exception(e, hint: { background: false })
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.generate_extra(job)
25
- extra = {
26
- "delayed_job.id": job.id.to_s,
27
- "delayed_job.priority": job.priority,
28
- "delayed_job.attempts": job.attempts,
29
- "delayed_job.run_at": job.run_at,
30
- "delayed_job.locked_at": job.locked_at,
31
- "delayed_job.locked_by": job.locked_by,
32
- "delayed_job.queue": job.queue,
33
- "delayed_job.created_at": job.created_at,
34
- "delayed_job.last_error": job.last_error&.byteslice(0..1000),
35
- "delayed_job.handler": job.handler&.byteslice(0..1000)
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
- extra[:"active_job.#{key}"] = value
50
+ context[ACTIVE_JOB_CONTEXT_KEY][key.to_sym] = value
41
51
  end
42
52
  end
43
53
 
44
- extra
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
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module DelayedJob
3
- VERSION = "4.3.0"
3
+ VERSION = "4.5.0"
4
4
  end
5
5
  end
@@ -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/sentry-delayed_job/CHANGELOG.md"
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.3.0"
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.3.0
4
+ version: 4.5.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-03-12 00:00:00.000000000 Z
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.3.0
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.3.0
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/sentry-delayed_job/CHANGELOG.md
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.0.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