sentry-delayed_job 4.5.0 → 4.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 056a402ebaef3f63d8e96643e694307e20b77c480c084128248ea6adf9d4bccc
4
- data.tar.gz: f07073033d5cbb695c6dabe5a00bef1cbba3b22fdbb0320a2dcc4977bfb34f99
3
+ metadata.gz: 3e1435dddf32b86475f533fda7ed51c1427ddfbb08e47841b772f59abc25350a
4
+ data.tar.gz: a52316de77fa046c09e99fcfdb45e7f972b6c657a05b1a1c7b0f45610e19cb1a
5
5
  SHA512:
6
- metadata.gz: aa7deb183518153ca434001065cecb46d79f23e948b282ec031bf93cc61ec9c744427949f714b19ad9b0a5f5c7cc80cdb4583124efeaa1ea696fe85476865a00
7
- data.tar.gz: 4890714298f5f9dfe5704fd441630524fb3adcf56f068243357259a136f94026b33e34a55c788bb305dff54b62a46a615043b406b1319cfa4a83e38b22e660d4
6
+ metadata.gz: 35f1e86a50543958fdf9c7fa6b62a09a2d931f8dbb91d91ba48fe88f9e00f82da35489b09eaa7981b49e6e2d8778175a08a5fdcd8a8cbaeaf4e6bc1bb0709036
7
+ data.tar.gz: 2472a2c8b77194eff15ddbe0bc053ca0ce58a8b3fc3306a1b9d6b57696558495b89feb73cfdd909832b13dbeb1a8902f74b08cf0b19f96299d96840151eb0ef8
@@ -13,14 +13,21 @@ module Sentry
13
13
  next block.call(job, *args) unless Sentry.initialized?
14
14
 
15
15
  Sentry.with_scope do |scope|
16
- scope.set_contexts(**generate_contexts(job))
16
+ contexts = generate_contexts(job)
17
+ scope.set_transaction_name(contexts.dig(ACTIVE_JOB_CONTEXT_KEY, :job_class) || contexts.dig(DELAYED_JOB_CONTEXT_KEY, :job_class))
18
+ scope.set_contexts(**contexts)
17
19
  scope.set_tags("delayed_job.queue" => job.queue, "delayed_job.id" => job.id.to_s)
18
20
 
21
+ transaction = Sentry.start_transaction(name: scope.transaction_name, op: "delayed_job")
22
+ scope.set_span(transaction) if transaction
23
+
19
24
  begin
20
25
  block.call(job, *args)
26
+
27
+ finish_transaction(transaction, 200)
21
28
  rescue Exception => e
22
29
  capture_exception(e, job)
23
-
30
+ finish_transaction(transaction, 500)
24
31
  raise
25
32
  end
26
33
  end
@@ -40,7 +47,8 @@ module Sentry
40
47
  queue: job.queue,
41
48
  created_at: job.created_at,
42
49
  last_error: job.last_error&.byteslice(0..1000),
43
- handler: job.handler&.byteslice(0..1000)
50
+ handler: job.handler&.byteslice(0..1000),
51
+ job_class: compute_job_class(job.payload_object),
44
52
  }
45
53
 
46
54
  if job.payload_object.respond_to?(:job_data)
@@ -54,6 +62,15 @@ module Sentry
54
62
  context
55
63
  end
56
64
 
65
+ def self.compute_job_class(payload_object)
66
+ if payload_object.is_a? Delayed::PerformableMethod
67
+ klass = payload_object.object.is_a?(Class) ? payload_object.object.name : payload_object.object.class.name
68
+ "#{klass}##{payload_object.method_name}"
69
+ else
70
+ payload_object.class.name
71
+ end
72
+ end
73
+
57
74
  def self.capture_exception(exception, job)
58
75
  Sentry::DelayedJob.capture_exception(exception, hint: { background: false }) if report?(job)
59
76
  end
@@ -65,6 +82,13 @@ module Sentry
65
82
  # count at this point.
66
83
  job.attempts >= Delayed::Worker.max_attempts.pred
67
84
  end
85
+
86
+ def self.finish_transaction(transaction, status)
87
+ return unless transaction
88
+
89
+ transaction.set_http_status(status)
90
+ transaction.finish
91
+ end
68
92
  end
69
93
  end
70
94
  end
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module DelayedJob
3
- VERSION = "4.5.0"
3
+ VERSION = "4.6.1"
4
4
  end
5
5
  end
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
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.5.0"
25
+ spec.add_dependency "sentry-ruby-core", "~> 4.6.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.5.0
4
+ version: 4.6.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-05-27 00:00:00.000000000 Z
11
+ date: 2021-07-08 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.5.0
19
+ version: 4.6.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.5.0
26
+ version: 4.6.0
27
27
  description: A gem that provides DelayedJob integration for the Sentry error logger
28
28
  email: accounts@sentry.io
29
29
  executables: []
@@ -32,7 +32,6 @@ extra_rdoc_files:
32
32
  - README.md
33
33
  - LICENSE.txt
34
34
  files:
35
- - ".craft.yml"
36
35
  - ".gitignore"
37
36
  - ".rspec"
38
37
  - CHANGELOG.md
data/.craft.yml DELETED
@@ -1,19 +0,0 @@
1
- minVersion: '0.13.2'
2
- github:
3
- owner: getsentry
4
- repo: sentry-ruby
5
- changelogPolicy: simple
6
- preReleaseCommand: ruby ../.scripts/bump-version.rb
7
- releaseBranchPrefix: release-sentry-delayed_job
8
- statusProvider:
9
- name: github
10
- artifactProvider:
11
- name: github
12
- targets:
13
- - name: gem
14
- - name: registry
15
- type: sdk
16
- config:
17
- canonical: 'gem:sentry-delayed_job'
18
- - name: github
19
- tagPrefix: sentry-delayed_job-v