sentry-rails 0.3.0 → 4.1.3

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: b5a071161aa05eeabd788b6046086122bf11afb2cd4e7e681d314f6b951dc89c
4
- data.tar.gz: 897e542a17060febc1b030827f314cb524160790cc220d71e8f3a4f0d16ebd9b
3
+ metadata.gz: 81491f8d74dfb70ff29222476cc66bb08bf2e3b7e2b013b881a8c79b9992ca04
4
+ data.tar.gz: c2be7c2616fa93da1a096b4352b9b353745cc6972c27df72933908e700f7666a
5
5
  SHA512:
6
- metadata.gz: 68e1412f9c0270c5bd0cec50a381bd0a86e69500aa7db1a6170940c1f7d0a2cea030cb3b56fa2fb9eb36029330664de9725f0d3c3ea054afcaab0dbee4661607
7
- data.tar.gz: 2f271a051f5876f18370ea58285dfc8e6848fb7d4bf263ee7e4065922200970882eba2112b902db34034b52cb82cd897bf96264cf9c96e42240de96a736c12c3
6
+ metadata.gz: 8d3b47180e068af27983bf72ab65b15bd0a96a312ab414f52b6724d82f1fbf17cab8093122778ed62b3990f5a9bd8ad8d32713562395bce88cd0b984f3490320
7
+ data.tar.gz: 02226dc92b5d3f4ee08d95cc5710f4ee534cf2f5a71c1f8124ee5135948038e39b238e1e674874cb4810589b05d46a26c21040069f589e37cb389fbab9463979
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.1.3
4
+
5
+ - Remove DelayedJobAdapter from ignored list [#1179](https://github.com/getsentry/sentry-ruby/pull/1179)
6
+
7
+ ## 4.1.2
8
+
9
+ - Use middleware instead of method override to handle rescued exceptions [#1168](https://github.com/getsentry/sentry-ruby/pull/1168)
10
+ - Fixes [#738](https://github.com/getsentry/sentry-ruby/issues/738)
11
+ - Adopt Integrable module [#1177](https://github.com/getsentry/sentry-ruby/pull/1177)
12
+
13
+ ## 4.1.1
14
+
15
+ - Use stricter dependency declaration [#1159](https://github.com/getsentry/sentry-ruby/pull/1159)
16
+
17
+ ## 4.1.0
18
+
19
+ - Merge & rename 2 Rack middlewares [#1147](https://github.com/getsentry/sentry-ruby/pull/1147)
20
+ - Fixes [#1153](https://github.com/getsentry/sentry-ruby/pull/1153)
21
+ - Removed `Sentry::Rack::Tracing` middleware and renamed `Sentry::Rack::CaptureException` to `Sentry::Rack::CaptureExceptions`
22
+ - Tidy up rails integration [#1150](https://github.com/getsentry/sentry-ruby/pull/1150)
23
+ - Check SDK initialization before running integrations [#1151](https://github.com/getsentry/sentry-ruby/pull/1151)
24
+ - Fixes [#1145](https://github.com/getsentry/sentry-ruby/pull/1145)
25
+
26
+ ## 4.0.0
27
+
28
+ - Only documents update for the official release and no API/feature changes.
29
+
3
30
  ## 0.3.0
4
31
 
5
32
  - Major API changes: [1123](https://github.com/getsentry/sentry-ruby/pull/1123)
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  rails_version = ENV["RAILS_VERSION"]
7
- rails_version = "6.0" if rails_version.nil?
7
+ rails_version = "6.1.0" if rails_version.nil?
8
8
 
9
9
  gem 'activerecord-jdbcmysql-adapter', platform: :jruby
10
10
  gem "jdbc-sqlite3", platform: :jruby
@@ -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"
data/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver)
18
18
 
19
19
 
20
- [Documentation](https://docs.sentry.io/clients/ruby/) | [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
20
+ [Documentation](https://docs.sentry.io/platforms/ruby/guides/rails/) | [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
21
21
 
22
22
  The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
23
23
 
@@ -50,3 +50,36 @@ Sentry.init do |config|
50
50
  end
51
51
  ```
52
52
 
53
+ ### Performance Monitoring
54
+
55
+ You can activate performance monitoring by enabling traces sampling:
56
+
57
+ ```ruby
58
+ Sentry.init do |config|
59
+ # set a uniform sample rate between 0.0 and 1.0
60
+ config.traces_sample_rate = 0.2
61
+
62
+ # or control sampling dynamically
63
+ config.traces_sampler = lambda do |sampling_context|
64
+ # sampling_context[:transaction_context] contains the information about the transaction
65
+ # sampling_context[:parent_sampled] contains the transaction's parent's sample decision
66
+ true # return value can be a boolean or a float between 0.0 and 1.0
67
+ end
68
+ end
69
+ ```
70
+
71
+ Currently, it tracks the following Rails instrumentation events:
72
+
73
+ - ActiveRecord
74
+ - `sql.active_record`
75
+ - ActionController
76
+ - `process_action.action_controller`
77
+ - ActionView
78
+ - `render_template.action_view`
79
+ - `render_partial.action_view`
80
+ - `render_collection.action_view`
81
+
82
+ To lean more about performance monitoring, please visit the [official documentation](https://docs.sentry.io/platforms/ruby/guides/rails/performance/).
83
+
84
+
85
+
@@ -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
@@ -3,7 +3,6 @@ module Sentry
3
3
  module ActiveJobExtensions
4
4
  ALREADY_SUPPORTED_SENTRY_ADAPTERS = %w(
5
5
  ActiveJob::QueueAdapters::SidekiqAdapter
6
- ActiveJob::QueueAdapters::DelayedJobAdapter
7
6
  ).freeze
8
7
 
9
8
  def self.included(base)
@@ -26,7 +25,7 @@ module Sentry
26
25
  rescue_handler_result = rescue_with_handler(e)
27
26
  return rescue_handler_result if rescue_handler_result
28
27
 
29
- Sentry.capture_exception(e, :extra => sentry_context(job))
28
+ Sentry::Rails.capture_exception(e, extra: sentry_context(job))
30
29
  raise e
31
30
  end
32
31
 
@@ -14,7 +14,10 @@ module Sentry
14
14
 
15
15
  def inject
16
16
  @subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
17
- add(name, started, finished, unique_id, data)
17
+ # we only record events that has a started timestamp
18
+ if started.is_a?(Time)
19
+ add(name, started, finished, unique_id, data)
20
+ end
18
21
  end
19
22
  end
20
23
 
@@ -0,0 +1,19 @@
1
+ module Sentry
2
+ module Rails
3
+ class CaptureExceptions < Sentry::Rack::CaptureExceptions
4
+ private
5
+
6
+ def collect_exception(env)
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)
16
+ end
17
+ end
18
+ end
19
+ 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
- require "sentry/rails/capture_exception"
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"
@@ -8,12 +9,35 @@ require "sentry/rails/overrides/streaming_reporter"
8
9
 
9
10
  module Sentry
10
11
  class Railtie < ::Rails::Railtie
12
+ # middlewares can't be injected after initialize
11
13
  initializer "sentry.use_rack_middleware" do |app|
12
- app.config.middleware.insert 0, Sentry::Rails::CaptureException
13
- app.config.middleware.insert 0, Sentry::Rack::Tracing
14
+ # need to be placed at first to capture as many errors as possible
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
- initializer 'sentry.action_controller' do
20
+ config.after_initialize do
21
+ next unless Sentry.initialized?
22
+
23
+ configure_sentry_logger
24
+ extend_controller_methods
25
+ extend_active_job
26
+ override_streaming_reporter
27
+ setup_backtrace_cleanup_callback
28
+ inject_breadcrumbs_logger
29
+ activate_tracing
30
+ end
31
+
32
+ def configure_sentry_logger
33
+ Sentry.configuration.logger = ::Rails.logger
34
+ end
35
+
36
+ def extend_active_job
37
+ ActiveJob::Base.send(:prepend, Sentry::Rails::ActiveJobExtensions)
38
+ end
39
+
40
+ def extend_controller_methods
17
41
  ActiveSupport.on_load :action_controller do
18
42
  include Sentry::Rails::ControllerMethods
19
43
  include Sentry::Rails::ControllerTransaction
@@ -21,51 +45,32 @@ module Sentry
21
45
  end
22
46
  end
23
47
 
24
- initializer 'sentry.action_view' do
25
- ActiveSupport.on_load :action_view do
26
- ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
48
+ def inject_breadcrumbs_logger
49
+ if Sentry.configuration.breadcrumbs_logger.include?(:active_support_logger)
50
+ require 'sentry/rails/breadcrumb/active_support_logger'
51
+ Sentry::Rails::Breadcrumb::ActiveSupportLogger.inject
27
52
  end
28
53
  end
29
54
 
30
- config.after_initialize do
31
- Sentry.configuration.logger = ::Rails.logger
32
-
55
+ def setup_backtrace_cleanup_callback
33
56
  backtrace_cleaner = Sentry::Rails::BacktraceCleaner.new
34
57
 
35
58
  Sentry.configuration.backtrace_cleanup_callback = lambda do |backtrace|
36
59
  backtrace_cleaner.clean(backtrace)
37
60
  end
61
+ end
38
62
 
39
- if Sentry.configuration.breadcrumbs_logger.include?(:active_support_logger)
40
- require 'sentry/rails/breadcrumb/active_support_logger'
41
- Sentry::Rails::Breadcrumb::ActiveSupportLogger.inject
42
- end
43
-
44
- if Sentry.configuration.rails.report_rescued_exceptions
45
- require 'sentry/rails/overrides/debug_exceptions_catcher'
46
- if defined?(::ActionDispatch::DebugExceptions)
47
- exceptions_class = ::ActionDispatch::DebugExceptions
48
- elsif defined?(::ActionDispatch::ShowExceptions)
49
- exceptions_class = ::ActionDispatch::ShowExceptions
50
- end
51
-
52
- exceptions_class.send(:prepend, Sentry::Rails::Overrides::DebugExceptionsCatcher)
63
+ def override_streaming_reporter
64
+ ActiveSupport.on_load :action_view do
65
+ ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
53
66
  end
67
+ end
54
68
 
69
+ def activate_tracing
55
70
  if Sentry.configuration.tracing_enabled?
56
71
  Sentry::Rails::Tracing.subscribe_tracing_events
57
72
  Sentry::Rails::Tracing.patch_active_support_notifications
58
73
  end
59
74
  end
60
-
61
- initializer 'sentry.active_job' do
62
- ActiveSupport.on_load :active_job do
63
- require 'sentry/rails/active_job'
64
- end
65
- end
66
-
67
- # rake_tasks do
68
- # require 'sentry/integrations/tasks'
69
- # end
70
75
  end
71
76
  end
@@ -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 = "0.3.0"
3
+ VERSION = "4.1.3"
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", ">= 0.3.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: 0.3.0
4
+ version: 4.1.3
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-04 00:00:00.000000000 Z
11
+ date: 2021-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: sentry-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.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: 0.3.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: []
@@ -63,13 +63,13 @@ files:
63
63
  - lib/sentry/rails/active_job.rb
64
64
  - lib/sentry/rails/backtrace_cleaner.rb
65
65
  - lib/sentry/rails/breadcrumb/active_support_logger.rb
66
- - lib/sentry/rails/capture_exception.rb
66
+ - lib/sentry/rails/capture_exceptions.rb
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,9 +0,0 @@
1
- module Sentry
2
- module Rails
3
- class CaptureException < Sentry::Rack::CaptureException
4
- def collect_exception(env)
5
- super || env["action_dispatch.exception"]
6
- end
7
- end
8
- end
9
- end
@@ -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