sentry-rails 4.1.1 → 4.1.2

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: f1ded72e004f25631844145fc5a86d4e4a20e90417a42ac608a91b92fd5a0702
4
- data.tar.gz: 5b36ca31d954d72c0ee3f0407b3ad201285809b45439d580ccad910cf5f68d6f
3
+ metadata.gz: 8d6a1afa9da4c0ec517f7cf0b494f7965f9d6b30450ed005face3d28d541430e
4
+ data.tar.gz: 21a9be637731b712e430eee4652a3b98d7eef0475c7027833172b2dfb8a414fd
5
5
  SHA512:
6
- metadata.gz: b91264b7393b702a5f4e08e8ac37836dd97e5055eb214b37faa704930bb56ef681edbc7baabc8fcced668d2a78c4d10ab039715036a8196f6734a7ef5f429467
7
- data.tar.gz: bb6d1c2a6c051922126ba745350f1c003cf928309a6507867084f1a1833dd160a2ac6637cd909caadf69ac848d66a8789a1286409267c7aefbb74453836833c2
6
+ metadata.gz: 8d9c22704d42808bb82104540524468e696da6e24340b6e79216c1dfd0510a8e30099915fb9502c676ecc4f399d7bf29c48468708e2b29a2b9b656a771c8264d
7
+ data.tar.gz: 4eaff646e0096e0221c4389ff65ce50cd80a8ed4c03673718c1a5990b7a02f5d4639dffcb02a8622bc5f1f5b563c8c0dcaad8af77a72577d577c1744c81529a5
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.1.2
4
+
5
+ - Use middleware instead of method override to handle rescued exceptions [#1168](https://github.com/getsentry/sentry-ruby/pull/1168)
6
+ - Fixes [#738](https://github.com/getsentry/sentry-ruby/issues/738)
7
+ - Adopt Integrable module [#1177](https://github.com/getsentry/sentry-ruby/pull/1177)
8
+
3
9
  ## 4.1.1
4
10
 
5
11
  - Use stricter dependency declaration [#1159](https://github.com/getsentry/sentry-ruby/pull/1159)
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gem "sqlite3", platform: :ruby
12
12
 
13
13
  gem "rails", "~> #{rails_version}"
14
14
  gem "rspec-rails", "~> 4.0"
15
- gem "codecov"
15
+ gem "codecov", "0.2.12"
16
16
 
17
17
  gem "rake", "~> 12.0"
18
18
  gem "rspec", "~> 3.0"
@@ -1,14 +1,12 @@
1
1
  require "sentry-ruby"
2
+ require "sentry/integrable"
2
3
  require "sentry/rails/configuration"
3
4
  require "sentry/rails/railtie"
4
5
  require "sentry/rails/tracing"
5
6
 
6
7
  module Sentry
7
8
  module Rails
8
- META = { "name" => "sentry.ruby.rails", "version" => Sentry::Rails::VERSION }.freeze
9
- end
10
-
11
- def self.sdk_meta
12
- Sentry::Rails::META
9
+ extend Integrable
10
+ register_integration name: "rails", version: Sentry::Rails::VERSION
13
11
  end
14
12
  end
@@ -26,7 +26,7 @@ module Sentry
26
26
  rescue_handler_result = rescue_with_handler(e)
27
27
  return rescue_handler_result if rescue_handler_result
28
28
 
29
- Sentry.capture_exception(e, :extra => sentry_context(job))
29
+ Sentry::Rails.capture_exception(e, extra: sentry_context(job))
30
30
  raise e
31
31
  end
32
32
 
@@ -1,8 +1,18 @@
1
1
  module Sentry
2
2
  module Rails
3
3
  class CaptureExceptions < Sentry::Rack::CaptureExceptions
4
+ private
5
+
4
6
  def collect_exception(env)
5
- super || env["action_dispatch.exception"]
7
+ super || env["action_dispatch.exception"] || env["sentry.rescued_exception"]
8
+ end
9
+
10
+ def transaction_op
11
+ "rails.request".freeze
12
+ end
13
+
14
+ def capture_exception(exception)
15
+ Sentry::Rails.capture_exception(exception)
6
16
  end
7
17
  end
8
18
  end
@@ -3,13 +3,13 @@ module Sentry
3
3
  module ControllerMethods
4
4
  def capture_message(message, options = {})
5
5
  with_request_scope do
6
- Sentry.capture_message(message, **options)
6
+ Sentry::Rails.capture_message(message, **options)
7
7
  end
8
8
  end
9
9
 
10
10
  def capture_exception(exception, options = {})
11
11
  with_request_scope do
12
- Sentry.capture_exception(exception, **options)
12
+ Sentry::Rails.capture_exception(exception, **options)
13
13
  end
14
14
  end
15
15
 
@@ -2,10 +2,8 @@ module Sentry
2
2
  module Rails
3
3
  module ControllerTransaction
4
4
  def self.included(base)
5
- base.prepend_around_action do |controller, block|
5
+ base.prepend_before_action do |controller|
6
6
  Sentry.get_current_scope.set_transaction_name("#{controller.class}##{controller.action_name}")
7
- block.call
8
- Sentry.get_current_scope.transaction_names.pop
9
7
  end
10
8
  end
11
9
  end
@@ -3,7 +3,7 @@ module Sentry
3
3
  module Overrides
4
4
  module StreamingReporter
5
5
  def log_error(exception)
6
- Sentry.capture_exception(exception)
6
+ Sentry::Rails.capture_exception(exception)
7
7
  super
8
8
  end
9
9
  end
@@ -14,7 +14,7 @@ module Sentry
14
14
  end
15
15
 
16
16
  def log_error_with_raven(exception)
17
- Sentry.capture_exception(exception)
17
+ Sentry::Rails.capture_exception(exception)
18
18
  log_error_without_raven(exception)
19
19
  end
20
20
  end
@@ -1,5 +1,6 @@
1
1
  require "rails"
2
2
  require "sentry/rails/capture_exceptions"
3
+ require "sentry/rails/rescued_exception_interceptor"
3
4
  require "sentry/rails/backtrace_cleaner"
4
5
  require "sentry/rails/controller_methods"
5
6
  require "sentry/rails/controller_transaction"
@@ -10,7 +11,10 @@ module Sentry
10
11
  class Railtie < ::Rails::Railtie
11
12
  # middlewares can't be injected after initialize
12
13
  initializer "sentry.use_rack_middleware" do |app|
14
+ # need to be placed at first to capture as many errors as possible
13
15
  app.config.middleware.insert 0, Sentry::Rails::CaptureExceptions
16
+ # need to be placed at last to smuggle app exceptions via env
17
+ app.config.middleware.use(Sentry::Rails::RescuedExceptionInterceptor)
14
18
  end
15
19
 
16
20
  config.after_initialize do
@@ -19,7 +23,6 @@ module Sentry
19
23
  configure_sentry_logger
20
24
  extend_controller_methods
21
25
  extend_active_job
22
- override_exceptions_handling
23
26
  override_streaming_reporter
24
27
  setup_backtrace_cleanup_callback
25
28
  inject_breadcrumbs_logger
@@ -57,19 +60,6 @@ module Sentry
57
60
  end
58
61
  end
59
62
 
60
- def override_exceptions_handling
61
- if Sentry.configuration.rails.report_rescued_exceptions
62
- require 'sentry/rails/overrides/debug_exceptions_catcher'
63
- if defined?(::ActionDispatch::DebugExceptions)
64
- exceptions_class = ::ActionDispatch::DebugExceptions
65
- elsif defined?(::ActionDispatch::ShowExceptions)
66
- exceptions_class = ::ActionDispatch::ShowExceptions
67
- end
68
-
69
- exceptions_class.send(:prepend, Sentry::Rails::Overrides::DebugExceptionsCatcher)
70
- end
71
- end
72
-
73
63
  def override_streaming_reporter
74
64
  ActiveSupport.on_load :action_view do
75
65
  ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
@@ -0,0 +1,18 @@
1
+ module Sentry
2
+ module Rails
3
+ class RescuedExceptionInterceptor
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ begin
10
+ @app.call(env)
11
+ rescue => e
12
+ env["sentry.rescued_exception"] = e if Sentry.configuration.rails.report_rescued_exceptions
13
+ raise e
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Rails
3
- VERSION = "4.1.1"
3
+ VERSION = "4.1.2"
4
4
  end
5
5
  end
@@ -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", "~> 4.1.0"
26
+ spec.add_dependency "sentry-ruby", "~> 4.1.2"
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.1.1
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-21 00:00:00.000000000 Z
11
+ date: 2020-12-30 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.1.0
33
+ version: 4.1.2
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.1.0
40
+ version: 4.1.2
41
41
  description: A gem that provides Rails integration for the Sentry error logger
42
42
  email: accounts@sentry.io
43
43
  executables: []
@@ -67,9 +67,9 @@ files:
67
67
  - lib/sentry/rails/configuration.rb
68
68
  - lib/sentry/rails/controller_methods.rb
69
69
  - lib/sentry/rails/controller_transaction.rb
70
- - lib/sentry/rails/overrides/debug_exceptions_catcher.rb
71
70
  - lib/sentry/rails/overrides/streaming_reporter.rb
72
71
  - lib/sentry/rails/railtie.rb
72
+ - lib/sentry/rails/rescued_exception_interceptor.rb
73
73
  - lib/sentry/rails/tracing.rb
74
74
  - lib/sentry/rails/tracing/abstract_subscriber.rb
75
75
  - lib/sentry/rails/tracing/action_controller_subscriber.rb
@@ -1,19 +0,0 @@
1
- module Sentry
2
- module Rails
3
- module Overrides
4
- module DebugExceptionsCatcher
5
- def render_exception(env_or_request, exception)
6
- begin
7
- env = env_or_request.respond_to?(:env) ? env_or_request.env : env_or_request
8
- Sentry.with_scope do |scope|
9
- scope.set_rack_env(env)
10
- Sentry.capture_exception(exception)
11
- end
12
- rescue
13
- end
14
- super
15
- end
16
- end
17
- end
18
- end
19
- end