sentry-sidekiq 5.21.0 → 5.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -3
- data/Makefile +0 -4
- data/lib/sentry/sidekiq/cron/job.rb +42 -0
- data/lib/sentry/sidekiq/sentry_context_middleware.rb +30 -5
- data/lib/sentry/sidekiq/version.rb +1 -1
- data/sentry-sidekiq.gemspec +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83fbb1f91441c9adf737eaf26f68e5161de49eaf18cbcfb3f64ca104f1de4076
|
4
|
+
data.tar.gz: eb15ed9917c8677b982bfa5a81a080b80da54084051a5975ff0b678175ee0a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54831f113983325cc42c0e6bdf1765a01b1bf7769cade041270ab3c0475bb14ef95ee71b6461cf95f4c1139f0cfeea82cab0c846b3a4dad6e814bfa4fec423bc
|
7
|
+
data.tar.gz: 4bf2ad8e03051cf927c5f11c404bfe0a93e2cc17fc91f10b0233da2d14dc36cef4f20cf1386b871dcce982a857c8c617441495ab4a20f8bca5a1c9f6f45ef96c
|
data/Gemfile
CHANGED
@@ -12,9 +12,6 @@ gem "sentry-rails", path: "../sentry-rails"
|
|
12
12
|
# loofah changed the required ruby version in a patch so we need to explicitly pin it
|
13
13
|
gem "loofah", "2.20.0" if RUBY_VERSION.to_f < 2.5
|
14
14
|
|
15
|
-
# For https://github.com/ruby/psych/issues/655
|
16
|
-
gem "psych", "5.1.0"
|
17
|
-
|
18
15
|
sidekiq_version = ENV["SIDEKIQ_VERSION"]
|
19
16
|
sidekiq_version = "7.0" if sidekiq_version.nil?
|
20
17
|
sidekiq_version = Gem::Version.new(sidekiq_version)
|
@@ -28,4 +25,6 @@ end
|
|
28
25
|
|
29
26
|
gem "rails", "> 5.0.0"
|
30
27
|
|
28
|
+
gem "timecop"
|
29
|
+
|
31
30
|
eval_gemfile File.expand_path("../Gemfile", __dir__)
|
data/Makefile
CHANGED
@@ -12,6 +12,32 @@ module Sentry
|
|
12
12
|
module Sidekiq
|
13
13
|
module Cron
|
14
14
|
module Job
|
15
|
+
def self.enqueueing_method
|
16
|
+
::Sidekiq::Cron::Job.instance_methods.include?(:enque!) ? :enque! : :enqueue!
|
17
|
+
end
|
18
|
+
|
19
|
+
define_method(enqueueing_method) do |*args|
|
20
|
+
# make sure the current thread has a clean hub
|
21
|
+
Sentry.clone_hub_to_current_thread
|
22
|
+
|
23
|
+
Sentry.with_scope do |scope|
|
24
|
+
Sentry.with_session_tracking do
|
25
|
+
begin
|
26
|
+
scope.set_transaction_name("#{name} (#{klass})")
|
27
|
+
|
28
|
+
transaction = start_transaction(scope)
|
29
|
+
scope.set_span(transaction) if transaction
|
30
|
+
super(*args)
|
31
|
+
|
32
|
+
finish_transaction(transaction, 200)
|
33
|
+
rescue
|
34
|
+
finish_transaction(transaction, 500)
|
35
|
+
raise
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
15
41
|
def save
|
16
42
|
# validation failed, do nothing
|
17
43
|
return false unless super
|
@@ -34,6 +60,22 @@ module Sentry
|
|
34
60
|
|
35
61
|
true
|
36
62
|
end
|
63
|
+
|
64
|
+
def start_transaction(scope)
|
65
|
+
Sentry.start_transaction(
|
66
|
+
name: scope.transaction_name,
|
67
|
+
source: scope.transaction_source,
|
68
|
+
op: "queue.sidekiq-cron",
|
69
|
+
origin: "auto.queue.sidekiq.cron"
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
def finish_transaction(transaction, status_code)
|
74
|
+
return unless transaction
|
75
|
+
|
76
|
+
transaction.set_http_status(status_code)
|
77
|
+
transaction.finish
|
78
|
+
end
|
37
79
|
end
|
38
80
|
end
|
39
81
|
end
|
@@ -4,11 +4,24 @@ require "sentry/sidekiq/context_filter"
|
|
4
4
|
|
5
5
|
module Sentry
|
6
6
|
module Sidekiq
|
7
|
+
module Helpers
|
8
|
+
def set_span_data(span, id:, queue:, latency: nil, retry_count: nil)
|
9
|
+
if span
|
10
|
+
span.set_data("messaging.message.id", id)
|
11
|
+
span.set_data("messaging.destination.name", queue)
|
12
|
+
span.set_data("messaging.message.receive.latency", latency) if latency
|
13
|
+
span.set_data("messaging.message.retry.count", retry_count) if retry_count
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
7
18
|
class SentryContextServerMiddleware
|
8
|
-
|
19
|
+
include Sentry::Sidekiq::Helpers
|
20
|
+
|
21
|
+
OP_NAME = "queue.process"
|
9
22
|
SPAN_ORIGIN = "auto.queue.sidekiq"
|
10
23
|
|
11
|
-
def call(
|
24
|
+
def call(worker, job, queue)
|
12
25
|
return yield unless Sentry.initialized?
|
13
26
|
|
14
27
|
context_filter = Sentry::Sidekiq::ContextFilter.new(job)
|
@@ -23,7 +36,12 @@ module Sentry
|
|
23
36
|
scope.set_contexts(sidekiq: job.merge("queue" => queue))
|
24
37
|
scope.set_transaction_name(context_filter.transaction_name, source: :task)
|
25
38
|
transaction = start_transaction(scope, job["trace_propagation_headers"])
|
26
|
-
|
39
|
+
|
40
|
+
if transaction
|
41
|
+
scope.set_span(transaction)
|
42
|
+
|
43
|
+
set_span_data(transaction, id: job["jid"], queue: queue, latency: ((Time.now.to_f - job["enqueued_at"]) * 1000).to_i, retry_count: job["retry_count"] || 0)
|
44
|
+
end
|
27
45
|
|
28
46
|
begin
|
29
47
|
yield
|
@@ -63,13 +81,20 @@ module Sentry
|
|
63
81
|
end
|
64
82
|
|
65
83
|
class SentryContextClientMiddleware
|
66
|
-
|
84
|
+
include Sentry::Sidekiq::Helpers
|
85
|
+
|
86
|
+
def call(worker_class, job, queue, _redis_pool)
|
67
87
|
return yield unless Sentry.initialized?
|
68
88
|
|
69
89
|
user = Sentry.get_current_scope.user
|
70
90
|
job["sentry_user"] = user unless user.empty?
|
71
91
|
job["trace_propagation_headers"] ||= Sentry.get_trace_propagation_headers
|
72
|
-
|
92
|
+
|
93
|
+
Sentry.with_child_span(op: "queue.publish", description: worker_class.to_s) do |span|
|
94
|
+
set_span_data(span, id: job["jid"], queue: queue)
|
95
|
+
|
96
|
+
yield
|
97
|
+
end
|
73
98
|
end
|
74
99
|
end
|
75
100
|
end
|
data/sentry-sidekiq.gemspec
CHANGED
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_dependency "sentry-ruby", "~> 5.
|
33
|
+
spec.add_dependency "sentry-ruby", "~> 5.22.0"
|
34
34
|
spec.add_dependency "sidekiq", ">= 3.0"
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.22.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-12-04 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.22.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.22.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sidekiq
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,15 +69,15 @@ files:
|
|
69
69
|
- lib/sentry/sidekiq/sentry_context_middleware.rb
|
70
70
|
- lib/sentry/sidekiq/version.rb
|
71
71
|
- sentry-sidekiq.gemspec
|
72
|
-
homepage: https://github.com/getsentry/sentry-ruby/tree/5.
|
72
|
+
homepage: https://github.com/getsentry/sentry-ruby/tree/5.22.0/sentry-sidekiq
|
73
73
|
licenses:
|
74
74
|
- MIT
|
75
75
|
metadata:
|
76
|
-
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
77
|
-
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
78
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.
|
76
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.22.0/sentry-sidekiq
|
77
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.22.0/sentry-sidekiq
|
78
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.22.0/CHANGELOG.md
|
79
79
|
bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
|
80
|
-
documentation_uri: http://www.rubydoc.info/gems/sentry-sidekiq/5.
|
80
|
+
documentation_uri: http://www.rubydoc.info/gems/sentry-sidekiq/5.22.0
|
81
81
|
post_install_message:
|
82
82
|
rdoc_options: []
|
83
83
|
require_paths:
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.5.
|
96
|
+
rubygems_version: 3.5.22
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: A gem that provides Sidekiq integration for the Sentry error logger
|