sentry-rails 4.1.0 → 4.1.5
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 +4 -4
- data/CHANGELOG.md +30 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/sentry/rails.rb +3 -5
- data/lib/sentry/rails/active_job.rb +10 -7
- data/lib/sentry/rails/breadcrumb/active_support_logger.rb +17 -0
- data/lib/sentry/rails/capture_exceptions.rb +11 -1
- data/lib/sentry/rails/configuration.rb +1 -0
- data/lib/sentry/rails/controller_methods.rb +2 -2
- data/lib/sentry/rails/controller_transaction.rb +1 -3
- data/lib/sentry/rails/overrides/streaming_reporter.rb +2 -2
- data/lib/sentry/rails/railtie.rb +6 -16
- data/lib/sentry/rails/rescued_exception_interceptor.rb +29 -0
- data/lib/sentry/rails/tracing/action_controller_subscriber.rb +3 -0
- data/lib/sentry/rails/tracing/action_view_subscriber.rb +3 -11
- data/lib/sentry/rails/version.rb +1 -1
- data/sentry-rails.gemspec +1 -1
- metadata +7 -7
- data/lib/sentry/rails/overrides/debug_exceptions_catcher.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea1c3fea4d0f1f017e5b56786e85414e459a181e8e4cebe2a45374b6c3e648dc
|
4
|
+
data.tar.gz: b41da6b3dc3a3a7836ed533029821b4f53dc40e8b7cb0d10023a52af13236218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359b3757908046fa6dfde636715b598a6977c3a131b11e4a7f8d8df3666246e867867ca3c32161bbb645fe9bc0110c50efac415ed42b4db754e21cf36878af86
|
7
|
+
data.tar.gz: 4605d701de78b04adc04c74dc7b7dd1a1e02c1d500a663965d4ba9de35cf35db4a70331d21afd2b2c07a5c2917d2ccb0e2b7a7cced8f5026188e189cf119ecdb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.1.5
|
4
|
+
|
5
|
+
- Add `ActionDispatch::Http::MimeNegotiation::InvalidType` to the list of default ignored Rails exceptions [#1215](https://github.com/getsentry/sentry-ruby/pull/1215) (by @agrobbin)
|
6
|
+
- Continue ActiveJob execution if Sentry is not initialized [#1217](https://github.com/getsentry/sentry-ruby/pull/1217)
|
7
|
+
- Fixes [#1211](https://github.com/getsentry/sentry-ruby/issues/1211) and [#1216](https://github.com/getsentry/sentry-ruby/issues/1216)
|
8
|
+
- Only extend ActiveJob when it's defined [#1218](https://github.com/getsentry/sentry-ruby/pull/1218)
|
9
|
+
- Fixes [#1210](https://github.com/getsentry/sentry-ruby/issues/1210)
|
10
|
+
- Filter out redundant event/payload from breadcrumbs logger [#1222](https://github.com/getsentry/sentry-ruby/pull/1222)
|
11
|
+
- Copy request env before Rails' ShowExceptions middleware [#1223](https://github.com/getsentry/sentry-ruby/pull/1223)
|
12
|
+
- Don't subscribe render_partial and render_collection events [#1224](https://github.com/getsentry/sentry-ruby/pull/1224)
|
13
|
+
|
14
|
+
## 4.1.4
|
15
|
+
|
16
|
+
- Don't include headers & request info in tracing span or breadcrumb [#1199](https://github.com/getsentry/sentry-ruby/pull/1199)
|
17
|
+
- Don't run RescuedExceptionInterceptor unless Sentry is initialized [#1204](https://github.com/getsentry/sentry-ruby/pull/1204)
|
18
|
+
|
19
|
+
## 4.1.3
|
20
|
+
|
21
|
+
- Remove DelayedJobAdapter from ignored list [#1179](https://github.com/getsentry/sentry-ruby/pull/1179)
|
22
|
+
|
23
|
+
## 4.1.2
|
24
|
+
|
25
|
+
- Use middleware instead of method override to handle rescued exceptions [#1168](https://github.com/getsentry/sentry-ruby/pull/1168)
|
26
|
+
- Fixes [#738](https://github.com/getsentry/sentry-ruby/issues/738)
|
27
|
+
- Adopt Integrable module [#1177](https://github.com/getsentry/sentry-ruby/pull/1177)
|
28
|
+
|
29
|
+
## 4.1.1
|
30
|
+
|
31
|
+
- Use stricter dependency declaration [#1159](https://github.com/getsentry/sentry-ruby/pull/1159)
|
32
|
+
|
3
33
|
## 4.1.0
|
4
34
|
|
5
35
|
- Merge & rename 2 Rack middlewares [#1147](https://github.com/getsentry/sentry-ruby/pull/1147)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Sentry.init do |config|
|
|
44
44
|
# the default value is true
|
45
45
|
config.rails.report_rescued_exceptions = true
|
46
46
|
|
47
|
-
# this gem also provides a new breadcrumb logger that accepts
|
47
|
+
# this gem also provides a new breadcrumb logger that accepts instrumentations from ActiveSupport
|
48
48
|
# it's not activated by default, but you can enable it with
|
49
49
|
config.breadcrumbs_logger = [:active_support_logger]
|
50
50
|
end
|
data/lib/sentry/rails.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
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,18 +3,21 @@ 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)
|
10
9
|
base.class_eval do
|
11
10
|
around_perform do |job, block|
|
12
|
-
if
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
if Sentry.initialized?
|
12
|
+
if already_supported_by_specific_integration?(job)
|
13
|
+
block.call
|
14
|
+
else
|
15
|
+
Sentry.with_scope do
|
16
|
+
capture_and_reraise_with_sentry(job, block)
|
17
|
+
end
|
17
18
|
end
|
19
|
+
else
|
20
|
+
block.call
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -26,7 +29,7 @@ module Sentry
|
|
26
29
|
rescue_handler_result = rescue_with_handler(e)
|
27
30
|
return rescue_handler_result if rescue_handler_result
|
28
31
|
|
29
|
-
Sentry.capture_exception(e, :
|
32
|
+
Sentry::Rails.capture_exception(e, extra: sentry_context(job))
|
30
33
|
raise e
|
31
34
|
end
|
32
35
|
|
@@ -3,7 +3,18 @@ module Sentry
|
|
3
3
|
module Breadcrumb
|
4
4
|
module ActiveSupportLogger
|
5
5
|
class << self
|
6
|
+
IGNORED_DATA_TYPES = [:request, :headers, :exception, :exception_object]
|
7
|
+
|
6
8
|
def add(name, started, _finished, _unique_id, data)
|
9
|
+
# skip Rails' internal events
|
10
|
+
return if name.start_with?("!")
|
11
|
+
|
12
|
+
if data.is_a?(Hash)
|
13
|
+
# we should only mutate the copy of the data
|
14
|
+
data = data.dup
|
15
|
+
cleanup_data(data)
|
16
|
+
end
|
17
|
+
|
7
18
|
crumb = Sentry::Breadcrumb.new(
|
8
19
|
data: data,
|
9
20
|
category: name,
|
@@ -12,6 +23,12 @@ module Sentry
|
|
12
23
|
Sentry.add_breadcrumb(crumb)
|
13
24
|
end
|
14
25
|
|
26
|
+
def cleanup_data(data)
|
27
|
+
IGNORED_DATA_TYPES.each do |key|
|
28
|
+
data.delete(key) if data.key?(key)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
15
32
|
def inject
|
16
33
|
@subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
|
17
34
|
# we only record events that has a started timestamp
|
@@ -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
|
@@ -20,6 +20,7 @@ module Sentry
|
|
20
20
|
'ActionController::RoutingError',
|
21
21
|
'ActionController::UnknownAction',
|
22
22
|
'ActionController::UnknownFormat',
|
23
|
+
'ActionDispatch::Http::MimeNegotiation::InvalidType',
|
23
24
|
'ActionController::UnknownHttpMethod',
|
24
25
|
'ActionDispatch::Http::Parameters::ParseError',
|
25
26
|
'ActiveJob::DeserializationError', # Can cause infinite loops
|
@@ -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.
|
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
|
data/lib/sentry/rails/railtie.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
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"
|
6
|
-
require "sentry/rails/active_job"
|
7
7
|
require "sentry/rails/overrides/streaming_reporter"
|
8
8
|
|
9
9
|
module Sentry
|
10
10
|
class Railtie < ::Rails::Railtie
|
11
11
|
# middlewares can't be injected after initialize
|
12
12
|
initializer "sentry.use_rack_middleware" do |app|
|
13
|
+
# need to be placed at first to capture as many errors as possible
|
13
14
|
app.config.middleware.insert 0, Sentry::Rails::CaptureExceptions
|
15
|
+
# need to be placed at last to smuggle app exceptions via env
|
16
|
+
app.config.middleware.use(Sentry::Rails::RescuedExceptionInterceptor)
|
14
17
|
end
|
15
18
|
|
16
19
|
config.after_initialize do
|
@@ -18,8 +21,7 @@ module Sentry
|
|
18
21
|
|
19
22
|
configure_sentry_logger
|
20
23
|
extend_controller_methods
|
21
|
-
extend_active_job
|
22
|
-
override_exceptions_handling
|
24
|
+
extend_active_job if defined?(ActiveJob)
|
23
25
|
override_streaming_reporter
|
24
26
|
setup_backtrace_cleanup_callback
|
25
27
|
inject_breadcrumbs_logger
|
@@ -31,6 +33,7 @@ module Sentry
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def extend_active_job
|
36
|
+
require "sentry/rails/active_job"
|
34
37
|
ActiveJob::Base.send(:prepend, Sentry::Rails::ActiveJobExtensions)
|
35
38
|
end
|
36
39
|
|
@@ -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,29 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
class RescuedExceptionInterceptor
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
return @app.call(env) unless Sentry.initialized?
|
10
|
+
|
11
|
+
begin
|
12
|
+
@app.call(env)
|
13
|
+
rescue => e
|
14
|
+
request = ActionDispatch::Request.new(env)
|
15
|
+
|
16
|
+
# Rails' ShowExceptions#render_exception will mutate env for the exceptions app
|
17
|
+
# so we need to hold a copy of env to report the accurate data (like request's url)
|
18
|
+
if request.show_exceptions?
|
19
|
+
scope = Sentry.get_current_scope
|
20
|
+
scope.set_rack_env(scope.rack_env.dup)
|
21
|
+
end
|
22
|
+
|
23
|
+
env["sentry.rescued_exception"] = e if Sentry.configuration.rails.report_rescued_exceptions
|
24
|
+
raise e
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -15,6 +15,9 @@ module Sentry
|
|
15
15
|
description: "#{controller}##{action}",
|
16
16
|
duration: duration
|
17
17
|
) do |span|
|
18
|
+
payload = payload.dup
|
19
|
+
payload.delete(:headers)
|
20
|
+
payload.delete(:request)
|
18
21
|
span.set_data(:payload, payload)
|
19
22
|
span.set_http_status(payload[:status])
|
20
23
|
end
|
@@ -2,19 +2,11 @@ module Sentry
|
|
2
2
|
module Rails
|
3
3
|
module Tracing
|
4
4
|
class ActionViewSubscriber < AbstractSubscriber
|
5
|
-
|
5
|
+
EVENT_NAME = "render_template.action_view".freeze
|
6
6
|
|
7
7
|
def self.subscribe!
|
8
|
-
|
9
|
-
|
10
|
-
record_on_current_span(op: event_name, start_timestamp: payload[:start_timestamp], description: payload[:identifier], duration: duration)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.unsubscribe!
|
16
|
-
EVENT_NAMES.each do |event_name|
|
17
|
-
ActiveSupport::Notifications.unsubscribe(event_name)
|
8
|
+
subscribe_to_event(EVENT_NAME) do |event_name, duration, payload|
|
9
|
+
record_on_current_span(op: event_name, start_timestamp: payload[:start_timestamp], description: payload[:identifier], duration: duration)
|
18
10
|
end
|
19
11
|
end
|
20
12
|
end
|
data/lib/sentry/rails/version.rb
CHANGED
data/sentry-rails.gemspec
CHANGED
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.
|
4
|
+
version: 4.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-21 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: 4.1.
|
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.
|
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
|