sentry-resque 5.0.1 → 5.1.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: c21e7d2738e31a977eec92cbc4c220b686905fe975fc1861b979fdf3fd8e05f2
4
- data.tar.gz: 442bab6f763bccf4ea59575f3a8d44a8c839aa6e7ace39cc1d19e17ff08ea940
3
+ metadata.gz: 47ed5386880ace81cea24fd9d6a2e3a71169c8b7edf520335666107101bafaf9
4
+ data.tar.gz: 288dbf76154789de5192033c4679061add2387af8413fb2c56667b4e66a73d7c
5
5
  SHA512:
6
- metadata.gz: aa9eb3d52fda08747079d786ad55bb6e46fbda96e51f9223645a91c331ef423d330c0daa9ed009863e799a3ca57ceffc4a8a2a47d0a70d2df0e54206fa49c0bb
7
- data.tar.gz: f67024f6f622e74199e9c9fc1e8ac2202f7857c4916bc9bdf501ba88e3c1f257f7b00122e551a274d78a1f1784efbc560d3a1bde4ed7a89c0c47175b2468fea8
6
+ metadata.gz: 8ca1d97342063ef49772edd169ee0c4bcacdba8b3352ec0759baf2e5a27ffee25b3d4b3b584bdde0b145fb4b72908499688ab74f4d91090881686ba5649bdb80
7
+ data.tar.gz: 20904c4043323ff3104302a28d9c865e7c150738dfe3e79924b71a22d004752d712adfe419cb4d004d78b76d8fbcbbc43b858ba0fe9d75641e1059911080fd5f
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Resque
3
- VERSION = "5.0.1"
3
+ VERSION = "5.1.1"
4
4
  end
5
5
  end
data/lib/sentry/resque.rb CHANGED
@@ -5,63 +5,75 @@ require "resque"
5
5
  module Sentry
6
6
  module Resque
7
7
  def perform
8
- return super unless Sentry.initialized?
8
+ if Sentry.initialized?
9
+ SentryReporter.record(queue, worker, payload) do
10
+ super
11
+ end
12
+ else
13
+ super
14
+ end
15
+ end
9
16
 
10
- Sentry.with_scope do |scope|
11
- begin
12
- contexts = generate_contexts
13
- scope.set_contexts(**contexts)
14
- scope.set_tags("resque.queue" => queue)
17
+ class SentryReporter
18
+ class << self
19
+ def record(queue, worker, payload, &block)
20
+ Sentry.with_scope do |scope|
21
+ begin
22
+ contexts = generate_contexts(queue, worker, payload)
23
+ scope.set_contexts(**contexts)
24
+ scope.set_tags("resque.queue" => queue)
15
25
 
16
- scope.set_transaction_name(contexts.dig(:"Active-Job", :job_class) || contexts.dig(:"Resque", :job_class))
17
- transaction = Sentry.start_transaction(name: scope.transaction_name, op: "resque")
18
- scope.set_span(transaction) if transaction
26
+ scope.set_transaction_name(contexts.dig(:"Active-Job", :job_class) || contexts.dig(:"Resque", :job_class))
27
+ transaction = Sentry.start_transaction(name: scope.transaction_name, op: "resque")
28
+ scope.set_span(transaction) if transaction
19
29
 
20
- super
30
+ yield
21
31
 
22
- finish_transaction(transaction, 200)
23
- rescue Exception => exception
24
- ::Sentry::Resque.capture_exception(exception, hint: { background: false })
25
- finish_transaction(transaction, 500)
26
- raise
32
+ finish_transaction(transaction, 200)
33
+ rescue Exception => exception
34
+ ::Sentry::Resque.capture_exception(exception, hint: { background: false })
35
+ finish_transaction(transaction, 500)
36
+ raise
37
+ end
38
+ end
27
39
  end
28
- end
29
- end
30
40
 
31
- def generate_contexts
32
- context = {}
41
+ def generate_contexts(queue, worker, payload)
42
+ context = {}
33
43
 
34
- if payload["class"] == "ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper"
35
- active_job_payload = payload["args"].first
44
+ if payload["class"] == "ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper"
45
+ active_job_payload = payload["args"].first
36
46
 
37
- context[:"Active-Job"] = {
38
- job_class: active_job_payload["job_class"],
39
- job_id: active_job_payload["job_id"],
40
- arguments: active_job_payload["arguments"],
41
- executions: active_job_payload["executions"],
42
- exception_executions: active_job_payload["exception_executions"],
43
- locale: active_job_payload["locale"],
44
- enqueued_at: active_job_payload["enqueued_at"],
45
- queue: queue,
46
- worker: worker.to_s
47
- }
48
- else
49
- context[:"Resque"] = {
50
- job_class: payload["class"],
51
- arguments: payload["args"],
52
- queue: queue,
53
- worker: worker.to_s
54
- }
55
- end
47
+ context[:"Active-Job"] = {
48
+ job_class: active_job_payload["job_class"],
49
+ job_id: active_job_payload["job_id"],
50
+ arguments: active_job_payload["arguments"],
51
+ executions: active_job_payload["executions"],
52
+ exception_executions: active_job_payload["exception_executions"],
53
+ locale: active_job_payload["locale"],
54
+ enqueued_at: active_job_payload["enqueued_at"],
55
+ queue: queue,
56
+ worker: worker.to_s
57
+ }
58
+ else
59
+ context[:"Resque"] = {
60
+ job_class: payload["class"],
61
+ arguments: payload["args"],
62
+ queue: queue,
63
+ worker: worker.to_s
64
+ }
65
+ end
56
66
 
57
- context
58
- end
67
+ context
68
+ end
59
69
 
60
- def finish_transaction(transaction, status)
61
- return unless transaction
70
+ def finish_transaction(transaction, status)
71
+ return unless transaction
62
72
 
63
- transaction.set_http_status(status)
64
- transaction.finish
73
+ transaction.set_http_status(status)
74
+ transaction.finish
75
+ end
76
+ end
65
77
  end
66
78
  end
67
79
  end
@@ -22,6 +22,6 @@ 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", "~> 5.0.1"
25
+ spec.add_dependency "sentry-ruby-core", "~> 5.1.1"
26
26
  spec.add_dependency "resque", ">= 1.24"
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.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: 2022-01-23 00:00:00.000000000 Z
11
+ date: 2022-02-24 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: 5.0.1
19
+ version: 5.1.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: 5.0.1
26
+ version: 5.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: resque
29
29
  requirement: !ruby/object:Gem::Requirement