sentry-rails 4.1.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6d5b6ddf199bc5669f9e6808ad6e2b3673280224556627a11f5ce8b528cf322
4
- data.tar.gz: 701956e40f0024ed399289489c7d0e3caa4554266b1912a708502ded4a1facb4
3
+ metadata.gz: ea1c3fea4d0f1f017e5b56786e85414e459a181e8e4cebe2a45374b6c3e648dc
4
+ data.tar.gz: b41da6b3dc3a3a7836ed533029821b4f53dc40e8b7cb0d10023a52af13236218
5
5
  SHA512:
6
- metadata.gz: 8869449bc60e1eca6da3e2f9c08b638137ad51eeeb8776a534af4649bf31d7af2321bd37a104dc86efb1a364cd8744890ce980b4405af0c815030fb0e3e1e25b
7
- data.tar.gz: 426b79fa8bec147d34d3c0ef7c52ae7db4279df0d6b094858c20f63eb77f3e5b732ad42a280d059b00ce598d140fe0df476741df5b98dc3edb3d28473828d01a
6
+ metadata.gz: 359b3757908046fa6dfde636715b598a6977c3a131b11e4a7f8d8df3666246e867867ca3c32161bbb645fe9bc0110c50efac415ed42b4db754e21cf36878af86
7
+ data.tar.gz: 4605d701de78b04adc04c74dc7b7dd1a1e02c1d500a663965d4ba9de35cf35db4a70331d21afd2b2c07a5c2917d2ccb0e2b7a7cced8f5026188e189cf119ecdb
@@ -1,5 +1,16 @@
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
+
3
14
  ## 4.1.4
4
15
 
5
16
  - Don't include headers & request info in tracing span or breadcrumb [#1199](https://github.com/getsentry/sentry-ruby/pull/1199)
@@ -8,12 +8,16 @@ module Sentry
8
8
  def self.included(base)
9
9
  base.class_eval do
10
10
  around_perform do |job, block|
11
- if already_supported_by_specific_integration?(job)
12
- block.call
13
- else
14
- Sentry.with_scope do
15
- capture_and_reraise_with_sentry(job, block)
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
16
18
  end
19
+ else
20
+ block.call
17
21
  end
18
22
  end
19
23
  end
@@ -3,12 +3,16 @@ 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)
7
- if data.is_a?(Hash) && (data.key(:request) || data.key?(:headers))
9
+ # skip Rails' internal events
10
+ return if name.start_with?("!")
11
+
12
+ if data.is_a?(Hash)
8
13
  # we should only mutate the copy of the data
9
14
  data = data.dup
10
- data.delete(:request)
11
- data.delete(:headers)
15
+ cleanup_data(data)
12
16
  end
13
17
 
14
18
  crumb = Sentry::Breadcrumb.new(
@@ -19,6 +23,12 @@ module Sentry
19
23
  Sentry.add_breadcrumb(crumb)
20
24
  end
21
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
+
22
32
  def inject
23
33
  @subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
24
34
  # we only record events that has a started timestamp
@@ -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
@@ -4,7 +4,6 @@ require "sentry/rails/rescued_exception_interceptor"
4
4
  require "sentry/rails/backtrace_cleaner"
5
5
  require "sentry/rails/controller_methods"
6
6
  require "sentry/rails/controller_transaction"
7
- require "sentry/rails/active_job"
8
7
  require "sentry/rails/overrides/streaming_reporter"
9
8
 
10
9
  module Sentry
@@ -22,7 +21,7 @@ module Sentry
22
21
 
23
22
  configure_sentry_logger
24
23
  extend_controller_methods
25
- extend_active_job
24
+ extend_active_job if defined?(ActiveJob)
26
25
  override_streaming_reporter
27
26
  setup_backtrace_cleanup_callback
28
27
  inject_breadcrumbs_logger
@@ -34,6 +33,7 @@ module Sentry
34
33
  end
35
34
 
36
35
  def extend_active_job
36
+ require "sentry/rails/active_job"
37
37
  ActiveJob::Base.send(:prepend, Sentry::Rails::ActiveJobExtensions)
38
38
  end
39
39
 
@@ -11,6 +11,15 @@ module Sentry
11
11
  begin
12
12
  @app.call(env)
13
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
+
14
23
  env["sentry.rescued_exception"] = e if Sentry.configuration.rails.report_rescued_exceptions
15
24
  raise e
16
25
  end
@@ -2,19 +2,11 @@ module Sentry
2
2
  module Rails
3
3
  module Tracing
4
4
  class ActionViewSubscriber < AbstractSubscriber
5
- EVENT_NAMES = ["render_template.action_view", "render_partial.action_view", "render_collection.action_view"]
5
+ EVENT_NAME = "render_template.action_view".freeze
6
6
 
7
7
  def self.subscribe!
8
- EVENT_NAMES.each do |event_name|
9
- subscribe_to_event(event_name) do |event_name, duration, payload|
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
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Rails
3
- VERSION = "4.1.4"
3
+ VERSION = "4.1.5"
4
4
  end
5
5
  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.4
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: 2021-01-15 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails