sentry-delayed_job 5.16.1 → 5.17.0
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 +4 -4
- data/Rakefile +1 -1
- data/example/Gemfile +0 -1
- data/example/app.rb +0 -3
- data/lib/sentry/delayed_job/plugin.rb +37 -8
- data/lib/sentry/delayed_job/version.rb +1 -1
- data/sentry-delayed_job.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1982ed4c43b807a18a08dc82a6ff89c4145d043fb3f05c2450383fcf5b02e0fd
|
4
|
+
data.tar.gz: 43c8fcd55480b2d17cc8a872b43a93e3a43683527fa768437f395f64af9fa86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 572a579f738ec7d483be96b197c28cbb69a143c39c8fd90dec9a6d9c8bd17d7661139edf72bda94f273888401835deae62723b1aff137fa8e438a8f0893a80c3
|
7
|
+
data.tar.gz: f32de1898887c2a72654c085541d72a0b9d345fd72a2a721fd9fc6cef62e92bb6e2f7f7457700618fd52336a663bc7ecaf9288d8a182c9e06f36bb92426e86b8
|
data/Rakefile
CHANGED
data/example/Gemfile
CHANGED
data/example/app.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "delayed_job"
|
3
4
|
|
4
5
|
module Sentry
|
@@ -10,7 +11,12 @@ module Sentry
|
|
10
11
|
OP_NAME = "queue.delayed_job".freeze
|
11
12
|
|
12
13
|
callbacks do |lifecycle|
|
14
|
+
lifecycle.before(:enqueue) do |job, *args, &block|
|
15
|
+
inject_trace_data(job) if Sentry.initialized?
|
16
|
+
end
|
17
|
+
|
13
18
|
lifecycle.around(:invoke_job) do |job, *args, &block|
|
19
|
+
env = extract_trace_data(job)
|
14
20
|
next block.call(job, *args) unless Sentry.initialized?
|
15
21
|
|
16
22
|
Sentry.with_scope do |scope|
|
@@ -20,12 +26,7 @@ module Sentry
|
|
20
26
|
scope.set_contexts(**contexts)
|
21
27
|
scope.set_tags("delayed_job.queue" => job.queue, "delayed_job.id" => job.id.to_s)
|
22
28
|
|
23
|
-
transaction =
|
24
|
-
name: scope.transaction_name,
|
25
|
-
source: scope.transaction_source,
|
26
|
-
op: OP_NAME,
|
27
|
-
custom_sampling_context: contexts
|
28
|
-
)
|
29
|
+
transaction = start_transaction(scope, env, contexts)
|
29
30
|
scope.set_span(transaction) if transaction
|
30
31
|
|
31
32
|
begin
|
@@ -55,7 +56,7 @@ module Sentry
|
|
55
56
|
created_at: job.created_at,
|
56
57
|
last_error: job.last_error&.byteslice(0..1000),
|
57
58
|
handler: job.handler&.byteslice(0..1000),
|
58
|
-
job_class: compute_job_class(job.payload_object)
|
59
|
+
job_class: compute_job_class(job.payload_object)
|
59
60
|
}
|
60
61
|
|
61
62
|
if job.payload_object.respond_to?(:job_data)
|
@@ -70,7 +71,7 @@ module Sentry
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def self.compute_job_class(payload_object)
|
73
|
-
if payload_object.is_a?
|
74
|
+
if payload_object.is_a?(Delayed::PerformableMethod)
|
74
75
|
klass = payload_object.object.is_a?(Class) ? payload_object.object.name : payload_object.object.class.name
|
75
76
|
"#{klass}##{payload_object.method_name}"
|
76
77
|
else
|
@@ -91,12 +92,40 @@ module Sentry
|
|
91
92
|
job.attempts >= max_attempts
|
92
93
|
end
|
93
94
|
|
95
|
+
def self.start_transaction(scope, env, contexts)
|
96
|
+
options = { name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME }
|
97
|
+
transaction = Sentry.continue_trace(env, **options)
|
98
|
+
Sentry.start_transaction(transaction: transaction, custom_sampling_context: contexts, **options)
|
99
|
+
end
|
100
|
+
|
94
101
|
def self.finish_transaction(transaction, status)
|
95
102
|
return unless transaction
|
96
103
|
|
97
104
|
transaction.set_http_status(status)
|
98
105
|
transaction.finish
|
99
106
|
end
|
107
|
+
|
108
|
+
def self.inject_trace_data(job)
|
109
|
+
# active job style is handled in the sentry-rails/active_job extension more generally
|
110
|
+
# if someone enqueues manually with some other job class, we cannot make assumptions unfortunately
|
111
|
+
payload_object = job.payload_object
|
112
|
+
return unless payload_object.is_a?(Delayed::PerformableMethod)
|
113
|
+
|
114
|
+
# we will add the trace data to args and remove it again
|
115
|
+
# this is hacky but it's the only reliable way to survive the YAML serialization/deserialization
|
116
|
+
payload_object.args << { sentry: Sentry.get_trace_propagation_headers }
|
117
|
+
job.payload_object = payload_object
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.extract_trace_data(job)
|
121
|
+
payload_object = job.payload_object
|
122
|
+
return nil unless payload_object.is_a?(Delayed::PerformableMethod)
|
123
|
+
|
124
|
+
target_payload = payload_object.args.find { |a| a.is_a?(Hash) && a.key?(:sentry) }
|
125
|
+
return nil unless target_payload
|
126
|
+
payload_object.args.delete(target_payload)
|
127
|
+
target_payload[:sentry]
|
128
|
+
end
|
100
129
|
end
|
101
130
|
end
|
102
131
|
end
|
data/sentry-delayed_job.gemspec
CHANGED
@@ -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", "~> 5.
|
25
|
+
spec.add_dependency "sentry-ruby", "~> 5.17.0"
|
26
26
|
spec.add_dependency "delayed_job", ">= 4.0"
|
27
27
|
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: 5.
|
4
|
+
version: 5.17.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: 2024-
|
11
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sentry-ruby
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.17.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.
|
26
|
+
version: 5.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: delayed_job
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|