sentry-rails 4.2.2 → 4.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e22a278e6c74ad09c754d5270c227c1dd0989c90654d2f3f55d3ca06e06ad577
4
- data.tar.gz: c3bed6941cf8abdc306d20fd6ef7ebcecf08bb246b05921002423ac984a20d2b
3
+ metadata.gz: 7f1aafc591c356c77484bf061be1d4f8968588270e083d6ee94ada2f80054282
4
+ data.tar.gz: 74e40b15bdc17962037fd2b78b6695de5a405335a186f373c644dcb61b75aab6
5
5
  SHA512:
6
- metadata.gz: bdda28d73217516a73ffdf82ddc81687649255623a38ebcd3f9aa52d98bdf6ced7882a13c1d9dae8509eda5e1bc82a99c2762c8c5e89cd27153a98e81ba7d691
7
- data.tar.gz: 396aaacdf3db30251891de7bf4c5e6e5c27f5ce69eb6c9fc157f5fc70dada5c4fa782dac0dcf6050c6a8cf2474f680d801f4a7dac555b20f990aca077e8cfbc9
6
+ metadata.gz: 279ad65af3f35928746b8365bc494bf0384fde465414c1211cb565289bb7cbf1157c0649da6c835e4bbb79b928005eebba2805f387a52a57170bba876279b0fb
7
+ data.tar.gz: 6bf36d990e2c7f3ab51d8e5bb6bd2ec6873d924f2baa72796145502b2b4f04eea055c8c22a06a6bb8f0cbe92b2c92b15a7e29262f21252fce98be579f7e3fc38
data/.gitignore CHANGED
@@ -5,6 +5,7 @@
5
5
  /doc/
6
6
  /pkg/
7
7
  /spec/reports/
8
+ /spec/support/test_rails_app/db
8
9
  /tmp/
9
10
 
10
11
  # rspec failure tracking
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.3.0
4
+
5
+ ### Features
6
+
7
+ - Support performance monitoring on ActiveJob execution [#1304](https://github.com/getsentry/sentry-ruby/pull/1304)
8
+
9
+ ### Bug Fixes
10
+
11
+ - Prevent background workers from holding ActiveRecord connections [#1320](https://github.com/getsentry/sentry-ruby/pull/1320)
12
+
3
13
  ## 4.2.2
4
14
 
5
15
  - Always define Sentry::SendEventJob to avoid eager load issues [#1286](https://github.com/getsentry/sentry-ruby/pull/1286)
data/lib/sentry/rails.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "sentry-ruby"
2
2
  require "sentry/integrable"
3
+ require "sentry/rails/background_worker"
3
4
  require "sentry/rails/configuration"
4
5
  require "sentry/rails/engine"
5
6
  require "sentry/rails/railtie"
@@ -8,8 +8,8 @@ module Sentry
8
8
  if already_supported_by_specific_integration?(job)
9
9
  block.call
10
10
  else
11
- Sentry.with_scope do
12
- capture_and_reraise_with_sentry(job, block)
11
+ Sentry.with_scope do |scope|
12
+ capture_and_reraise_with_sentry(job, scope, block)
13
13
  end
14
14
  end
15
15
  else
@@ -19,10 +19,18 @@ module Sentry
19
19
  end
20
20
  end
21
21
 
22
- def capture_and_reraise_with_sentry(job, block)
22
+ def capture_and_reraise_with_sentry(job, scope, block)
23
+ scope.set_transaction_name(job.class.name)
24
+ transaction = Sentry.start_transaction(name: scope.transaction_name, op: "active_job")
25
+
26
+ scope.set_span(transaction) if transaction
27
+
23
28
  block.call
29
+
30
+ finish_transaction(transaction, 200)
24
31
  rescue Exception => e # rubocop:disable Lint/RescueException
25
32
  rescue_handler_result = rescue_with_handler(e)
33
+ finish_transaction(transaction, 500)
26
34
  return rescue_handler_result if rescue_handler_result
27
35
 
28
36
  Sentry::Rails.capture_exception(
@@ -36,6 +44,13 @@ module Sentry
36
44
  raise e
37
45
  end
38
46
 
47
+ def finish_transaction(transaction, status)
48
+ return unless transaction
49
+
50
+ transaction.set_http_status(status)
51
+ transaction.finish
52
+ end
53
+
39
54
  def already_supported_by_specific_integration?(job)
40
55
  Sentry.configuration.rails.skippable_job_adapters.include?(job.class.queue_adapter.class.to_s)
41
56
  end
@@ -0,0 +1,14 @@
1
+ module Sentry
2
+ class BackgroundWorker
3
+ alias_method :original_perform, :perform
4
+
5
+ def perform(&block)
6
+ @executor.post do
7
+ # make sure the background worker returns AR connection if it accidentally acquire one during serialization
8
+ ActiveRecord::Base.connection_pool.with_connection do
9
+ block.call
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -29,11 +29,16 @@ module Sentry
29
29
  Sentry::Rails.capture_exception(exception)
30
30
  end
31
31
 
32
- def finish_span(span, status_code)
33
- if @assets_regex.nil? || !span.name.match?(@assets_regex)
34
- span.set_http_status(status_code)
35
- span.finish
32
+ def start_transaction(env, scope)
33
+ transaction = super
34
+
35
+ return unless transaction
36
+
37
+ if @assets_regex && transaction.name.match?(@assets_regex)
38
+ transaction.instance_variable_set(:@sampled, false)
36
39
  end
40
+
41
+ transaction
37
42
  end
38
43
  end
39
44
  end
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Rails
3
- VERSION = "4.2.2"
3
+ VERSION = "4.3.0"
4
4
  end
5
5
  end
data/sentry-rails.gemspec CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "rails", ">= 5.0"
26
- spec.add_dependency "sentry-ruby-core", "~> 4.2.0"
26
+ spec.add_dependency "sentry-ruby-core", "~> 4.3.0"
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.2
4
+ version: 4.3.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: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.0
33
+ version: 4.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.0
40
+ version: 4.3.0
41
41
  description: A gem that provides Rails integration for the Sentry error logger
42
42
  email: accounts@sentry.io
43
43
  executables: []
@@ -62,6 +62,7 @@ files:
62
62
  - lib/sentry-rails.rb
63
63
  - lib/sentry/rails.rb
64
64
  - lib/sentry/rails/active_job.rb
65
+ - lib/sentry/rails/background_worker.rb
65
66
  - lib/sentry/rails/backtrace_cleaner.rb
66
67
  - lib/sentry/rails/breadcrumb/active_support_logger.rb
67
68
  - lib/sentry/rails/capture_exceptions.rb