sentry-resque 5.1.0 → 5.1.1

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: 34025217fa0ebd7f1ff06b033917df01b3a4dfc953015033f04c73ff204bc063
4
- data.tar.gz: 2d30113030ff36c739460693c90c1f891ca33a7751509d25c4fb688f7f42ec60
3
+ metadata.gz: 47ed5386880ace81cea24fd9d6a2e3a71169c8b7edf520335666107101bafaf9
4
+ data.tar.gz: 288dbf76154789de5192033c4679061add2387af8413fb2c56667b4e66a73d7c
5
5
  SHA512:
6
- metadata.gz: 6212927151bbfe622f4dff28f8c39252983200b14894084bb2c70e4dfbf648f8fe15270c00b10b6d5bd6bb6c8996dbf71b1c0ede41f170018239c3130d657030
7
- data.tar.gz: 35700d18f0762997f6ec9e04a8aed96a2e231b8366e25b937f89bd169b8c2a66f5f62a63f6c6330ce74ead93d27d7d7159d13cb48b48e8f080adb3135078a5f9
6
+ metadata.gz: 8ca1d97342063ef49772edd169ee0c4bcacdba8b3352ec0759baf2e5a27ffee25b3d4b3b584bdde0b145fb4b72908499688ab74f4d91090881686ba5649bdb80
7
+ data.tar.gz: 20904c4043323ff3104302a28d9c865e7c150738dfe3e79924b71a22d004752d712adfe419cb4d004d78b76d8fbcbbc43b858ba0fe9d75641e1059911080fd5f
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Resque
3
- VERSION = "5.1.0"
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.1.0"
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.1.0
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-02-10 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.1.0
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.1.0
26
+ version: 5.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: resque
29
29
  requirement: !ruby/object:Gem::Requirement