sentry-sidekiq 5.21.0 → 5.22.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: 5632cc22a856b3c11f324b13fc999f51ed2290add13636bdca2510c2574fccc0
4
- data.tar.gz: 100fee7c3cc7f38c9272be199f4f9c801bfd1f1afc2af02463667997a28c8c08
3
+ metadata.gz: 2aa3f4ae82ab8d6fc5fba46337262b12da3a0dd00d5e62ff4489ecf533b93869
4
+ data.tar.gz: 0f337deae3dd7d56fcf5309ba511ed42aa5f97ea6754e77cf931dc91eea9f099
5
5
  SHA512:
6
- metadata.gz: a1cc6a6ec0f6e4ff1bb3ac0d7b166471f71328168b2d480d136c79aea5a51dabcb3e70979a02578c602693f5ac1e324704941648c53a3902154a15549c9fef4d
7
- data.tar.gz: a1e9634862f76c9ea3216cd8b8e726f245eeb6a2f6db0d7b3e8683320545e468eea5cc7f537e427a028391fc807c6d489650616a61782a6718de0482f79d9111
6
+ metadata.gz: 611488068db6136aa27ec043d01e5787f0e8d7199ffbc3a6628ab1fd6bab8692f50e19dd42718e14c15623422704b53a8ca052bbdf1d194bbec7dfeb6ef5609c
7
+ data.tar.gz: 896d0b90b5ef1992d0137ba905e2db8b1c6a5c04ab2f6d3ee9b7f9cb1fc016796bb3dbcf42b550074c83677701c825e4609c019ef8fd91412bb02328ad3f2920
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
@@ -1,7 +1,3 @@
1
1
  build:
2
2
  bundle install
3
3
  gem build sentry-sidekiq.gemspec
4
-
5
- test:
6
- WITH_SENTRY_RAILS=1 bundle exec rspec spec/sentry/rails_spec.rb
7
- bundle exec rspec
@@ -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
+ return unless span
10
+
11
+ span.set_data(Span::DataConventions::MESSAGING_MESSAGE_ID, id)
12
+ span.set_data(Span::DataConventions::MESSAGING_DESTINATION_NAME, queue)
13
+ span.set_data(Span::DataConventions::MESSAGING_MESSAGE_RECEIVE_LATENCY, latency) if latency
14
+ span.set_data(Span::DataConventions::MESSAGING_MESSAGE_RETRY_COUNT, retry_count) if retry_count
15
+ end
16
+ end
17
+
7
18
  class SentryContextServerMiddleware
8
- OP_NAME = "queue.sidekiq"
19
+ include Sentry::Sidekiq::Helpers
20
+
21
+ OP_NAME = "queue.process"
9
22
  SPAN_ORIGIN = "auto.queue.sidekiq"
10
23
 
11
- def call(_worker, job, queue)
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,19 @@ 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
- scope.set_span(transaction) if transaction
39
+
40
+ if transaction
41
+ scope.set_span(transaction)
42
+
43
+ latency = ((Time.now.to_f - job["enqueued_at"]) * 1000).to_i if job["enqueued_at"]
44
+ set_span_data(
45
+ transaction,
46
+ id: job["jid"],
47
+ queue: queue,
48
+ latency: latency,
49
+ retry_count: job["retry_count"] || 0
50
+ )
51
+ end
27
52
 
28
53
  begin
29
54
  yield
@@ -63,13 +88,20 @@ module Sentry
63
88
  end
64
89
 
65
90
  class SentryContextClientMiddleware
66
- def call(_worker_class, job, _queue, _redis_pool)
91
+ include Sentry::Sidekiq::Helpers
92
+
93
+ def call(worker_class, job, queue, _redis_pool)
67
94
  return yield unless Sentry.initialized?
68
95
 
69
96
  user = Sentry.get_current_scope.user
70
97
  job["sentry_user"] = user unless user.empty?
71
98
  job["trace_propagation_headers"] ||= Sentry.get_trace_propagation_headers
72
- yield
99
+
100
+ Sentry.with_child_span(op: "queue.publish", description: worker_class.to_s) do |span|
101
+ set_span_data(span, id: job["jid"], queue: queue)
102
+
103
+ yield
104
+ end
73
105
  end
74
106
  end
75
107
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sentry
4
4
  module Sidekiq
5
- VERSION = "5.21.0"
5
+ VERSION = "5.22.1"
6
6
  end
7
7
  end
@@ -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.21.0"
33
+ spec.add_dependency "sentry-ruby", "~> 5.22.1"
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.21.0
4
+ version: 5.22.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: 2024-10-07 00:00:00.000000000 Z
11
+ date: 2024-12-16 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.21.0
19
+ version: 5.22.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.21.0
26
+ version: 5.22.1
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.21.0/sentry-sidekiq
72
+ homepage: https://github.com/getsentry/sentry-ruby/tree/5.22.1/sentry-sidekiq
73
73
  licenses:
74
74
  - MIT
75
75
  metadata:
76
- homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-sidekiq
77
- source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-sidekiq
78
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.21.0/CHANGELOG.md
76
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.22.1/sentry-sidekiq
77
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.22.1/sentry-sidekiq
78
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.22.1/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.21.0
80
+ documentation_uri: http://www.rubydoc.info/gems/sentry-sidekiq/5.22.1
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.16
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