sentry-resque 5.0.2 → 5.2.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: a3276450719b246b7eddb8d5b2378c4d6d2f82374a2e026f5264ed7152aa5f74
4
- data.tar.gz: 703626264624b1cd39b9cf6d614820c1ccbee204ebd3b7b290eaad7cc624a6df
3
+ metadata.gz: 915b11697f4ec7624e315220d15434d530dcce89b823a3504fae07311d419b1b
4
+ data.tar.gz: 36249ae2e06f3cbcf71db429905d2f362f42acffc09a5fa8cfd39ec74499ec5b
5
5
  SHA512:
6
- metadata.gz: 86579c723534a6022c1b06c6d4c72ccb48382ef59a7dfd515d8170822d9de44446f3dcfc8a8cae7ba9613b41d17c5f560730e48e5b018c9bab03b7896882ce53
7
- data.tar.gz: f7b61c04b1510db6233b70d11c07f51a6ec0ef37fd05633948bb0ee22bae76b218123996e15d3063fa122fc2516aef2b8c517ba86329a1150384039c1417d49a
6
+ metadata.gz: '08a305de6e4367e1027fe47a7a4eb6b94a32ac9807c86304a48e3ceaff998b175e02d1f7b0a4b538ef445150bc10d5a7b8cadc389a1ae9727953c74ead8b223b'
7
+ data.tar.gz: 24cd6907f3be8d948fff4ca51d6e5ade9c0ca7e108747e7fd9f6188dda011e3e3b5d6d4685c104a1b43e93fc1947f2ac8d035be817338b496710ec5793deccf9
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Resque
3
- VERSION = "5.0.2"
3
+ VERSION = "5.2.0"
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.2"
25
+ spec.add_dependency "sentry-ruby-core", "~> 5.2.0"
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.2
4
+ version: 5.2.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: 2022-01-31 00:00:00.000000000 Z
11
+ date: 2022-03-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: 5.0.2
19
+ version: 5.2.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: 5.0.2
26
+ version: 5.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: resque
29
29
  requirement: !ruby/object:Gem::Requirement