sentry-rails 4.0.0 → 4.1.4
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 +28 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/sentry/rails.rb +3 -5
- data/lib/sentry/rails/active_job.rb +1 -2
- data/lib/sentry/rails/breadcrumb/active_support_logger.rb +11 -1
- data/lib/sentry/rails/capture_exceptions.rb +19 -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 +39 -34
- data/lib/sentry/rails/rescued_exception_interceptor.rb +20 -0
- data/lib/sentry/rails/tracing/action_controller_subscriber.rb +3 -0
- data/lib/sentry/rails/version.rb +1 -1
- data/sentry-rails.gemspec +1 -1
- metadata +8 -8
- data/lib/sentry/rails/capture_exception.rb +0 -9
- 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: b6d5b6ddf199bc5669f9e6808ad6e2b3673280224556627a11f5ce8b528cf322
|
4
|
+
data.tar.gz: 701956e40f0024ed399289489c7d0e3caa4554266b1912a708502ded4a1facb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8869449bc60e1eca6da3e2f9c08b638137ad51eeeb8776a534af4649bf31d7af2321bd37a104dc86efb1a364cd8744890ce980b4405af0c815030fb0e3e1e25b
|
7
|
+
data.tar.gz: 426b79fa8bec147d34d3c0ef7c52ae7db4279df0d6b094858c20f63eb77f3e5b732ad42a280d059b00ce598d140fe0df476741df5b98dc3edb3d28473828d01a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.1.4
|
4
|
+
|
5
|
+
- Don't include headers & request info in tracing span or breadcrumb [#1199](https://github.com/getsentry/sentry-ruby/pull/1199)
|
6
|
+
- Don't run RescuedExceptionInterceptor unless Sentry is initialized [#1204](https://github.com/getsentry/sentry-ruby/pull/1204)
|
7
|
+
|
8
|
+
## 4.1.3
|
9
|
+
|
10
|
+
- Remove DelayedJobAdapter from ignored list [#1179](https://github.com/getsentry/sentry-ruby/pull/1179)
|
11
|
+
|
12
|
+
## 4.1.2
|
13
|
+
|
14
|
+
- Use middleware instead of method override to handle rescued exceptions [#1168](https://github.com/getsentry/sentry-ruby/pull/1168)
|
15
|
+
- Fixes [#738](https://github.com/getsentry/sentry-ruby/issues/738)
|
16
|
+
- Adopt Integrable module [#1177](https://github.com/getsentry/sentry-ruby/pull/1177)
|
17
|
+
|
18
|
+
## 4.1.1
|
19
|
+
|
20
|
+
- Use stricter dependency declaration [#1159](https://github.com/getsentry/sentry-ruby/pull/1159)
|
21
|
+
|
22
|
+
## 4.1.0
|
23
|
+
|
24
|
+
- Merge & rename 2 Rack middlewares [#1147](https://github.com/getsentry/sentry-ruby/pull/1147)
|
25
|
+
- Fixes [#1153](https://github.com/getsentry/sentry-ruby/pull/1153)
|
26
|
+
- Removed `Sentry::Rack::Tracing` middleware and renamed `Sentry::Rack::CaptureException` to `Sentry::Rack::CaptureExceptions`
|
27
|
+
- Tidy up rails integration [#1150](https://github.com/getsentry/sentry-ruby/pull/1150)
|
28
|
+
- Check SDK initialization before running integrations [#1151](https://github.com/getsentry/sentry-ruby/pull/1151)
|
29
|
+
- Fixes [#1145](https://github.com/getsentry/sentry-ruby/pull/1145)
|
30
|
+
|
3
31
|
## 4.0.0
|
4
32
|
|
5
33
|
- Only documents update for the official release and no API/feature changes.
|
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,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, :
|
28
|
+
Sentry::Rails.capture_exception(e, extra: sentry_context(job))
|
30
29
|
raise e
|
31
30
|
end
|
32
31
|
|
@@ -4,6 +4,13 @@ module Sentry
|
|
4
4
|
module ActiveSupportLogger
|
5
5
|
class << self
|
6
6
|
def add(name, started, _finished, _unique_id, data)
|
7
|
+
if data.is_a?(Hash) && (data.key(:request) || data.key?(:headers))
|
8
|
+
# we should only mutate the copy of the data
|
9
|
+
data = data.dup
|
10
|
+
data.delete(:request)
|
11
|
+
data.delete(:headers)
|
12
|
+
end
|
13
|
+
|
7
14
|
crumb = Sentry::Breadcrumb.new(
|
8
15
|
data: data,
|
9
16
|
category: name,
|
@@ -14,7 +21,10 @@ module Sentry
|
|
14
21
|
|
15
22
|
def inject
|
16
23
|
@subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
|
17
|
-
|
24
|
+
# we only record events that has a started timestamp
|
25
|
+
if started.is_a?(Time)
|
26
|
+
add(name, started, finished, unique_id, data)
|
27
|
+
end
|
18
28
|
end
|
19
29
|
end
|
20
30
|
|
@@ -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.
|
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,5 +1,6 @@
|
|
1
1
|
require "rails"
|
2
|
-
require "sentry/rails/
|
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
|
-
|
13
|
-
app.config.middleware.insert 0, Sentry::
|
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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
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
|
-
|
40
|
-
|
41
|
-
Sentry::Rails::
|
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,20 @@
|
|
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
|
+
env["sentry.rescued_exception"] = e if Sentry.configuration.rails.report_rescued_exceptions
|
15
|
+
raise e
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
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
|
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.
|
4
|
+
version: 4.1.4
|
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-15 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.
|
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.
|
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/
|
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,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
|