sentry-sidekiq 5.20.1 → 5.22.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: 2a4d7ced8fb73d400732c4f0a29e1a5a2ce71701f7592ade0c6a29c7490ce935
4
- data.tar.gz: 8c757b3826d25059f4923077080dd1e4e39a3caea22c45518a63910dd5965cef
3
+ metadata.gz: 83fbb1f91441c9adf737eaf26f68e5161de49eaf18cbcfb3f64ca104f1de4076
4
+ data.tar.gz: eb15ed9917c8677b982bfa5a81a080b80da54084051a5975ff0b678175ee0a38
5
5
  SHA512:
6
- metadata.gz: f128cb5a76b95111a9be6f8cfb703f6a0ec20770af90d26e1aea547d034bd5b91d3ae3aa059f70106b1ebaab5df4907a455ef0945fe7f2b812b09c89aebe6885
7
- data.tar.gz: 85fd7f607d2c62c59ba8721166e9f1c4c88a1aba5faa0ae43a48b4ea7a025a666f36aa5cb0d26635358152431616d6d03996603a775e6f3a0239027b962fbc6b
6
+ metadata.gz: 54831f113983325cc42c0e6bdf1765a01b1bf7769cade041270ab3c0475bb14ef95ee71b6461cf95f4c1139f0cfeea82cab0c846b3a4dad6e814bfa4fec423bc
7
+ data.tar.gz: 4bf2ad8e03051cf927c5f11c404bfe0a93e2cc17fc91f10b0233da2d14dc36cef4f20cf1386b871dcce982a857c8c617441495ab4a20f8bca5a1c9f6f45ef96c
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
  git_source(:github) { |name| "https://github.com/#{name}.git" }
3
5
 
@@ -10,9 +12,6 @@ gem "sentry-rails", path: "../sentry-rails"
10
12
  # loofah changed the required ruby version in a patch so we need to explicitly pin it
11
13
  gem "loofah", "2.20.0" if RUBY_VERSION.to_f < 2.5
12
14
 
13
- # For https://github.com/ruby/psych/issues/655
14
- gem "psych", "5.1.0"
15
-
16
15
  sidekiq_version = ENV["SIDEKIQ_VERSION"]
17
16
  sidekiq_version = "7.0" if sidekiq_version.nil?
18
17
  sidekiq_version = Gem::Version.new(sidekiq_version)
@@ -26,4 +25,6 @@ end
26
25
 
27
26
  gem "rails", "> 5.0.0"
28
27
 
28
+ gem "timecop"
29
+
29
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
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "sentry/ruby"
data/example/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gem "sidekiq"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sidekiq"
2
4
  require "sentry-sidekiq"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  class Configuration
3
5
  attr_reader :sidekiq
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  module Sidekiq
3
5
  class ContextFilter
4
- ACTIVEJOB_RESERVED_PREFIX_REGEX = /^_aj_/.freeze
5
- SIDEKIQ_NAME = "Sidekiq".freeze
6
+ ACTIVEJOB_RESERVED_PREFIX_REGEX = /^_aj_/
7
+ SIDEKIQ_NAME = "Sidekiq"
6
8
 
7
9
  attr_reader :context
8
10
 
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sentry/sidekiq/context_filter"
2
4
 
3
5
  module Sentry
@@ -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
- 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,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
- scope.set_span(transaction) if transaction
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
- def call(_worker_class, job, _queue, _redis_pool)
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
- yield
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
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  module Sidekiq
3
- VERSION = "5.20.1"
5
+ VERSION = "5.22.0"
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sidekiq"
2
4
  require "sentry-ruby"
3
5
  require "sentry/integrable"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "lib/sentry/sidekiq/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -28,6 +30,6 @@ Gem::Specification.new do |spec|
28
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
31
  spec.require_paths = ["lib"]
30
32
 
31
- spec.add_dependency "sentry-ruby", "~> 5.20.1"
33
+ spec.add_dependency "sentry-ruby", "~> 5.22.0"
32
34
  spec.add_dependency "sidekiq", ">= 3.0"
33
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.20.1
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-09-27 00:00:00.000000000 Z
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.20.1
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.20.1
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.20.1/sentry-sidekiq
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.20.1/sentry-sidekiq
77
- source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.20.1/sentry-sidekiq
78
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.20.1/CHANGELOG.md
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.20.1
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.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