bugsnag 6.20.0 → 6.21.0

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: cfe6701fa69f8d7c3c78476d17d127f921a6f730cdd3b618f92e6f7c2483da74
4
- data.tar.gz: '0857ab0742b7a33acfa39a60f4ecf9114f20b30293c78ef7bb1d1ba52ddef664'
3
+ metadata.gz: d25c44a654cbfc8684f28ea8ae1853f3aa482abc2741574662afb8368ab8c5b2
4
+ data.tar.gz: a5c2462967da4d5995a7e07715a310bf5290019943395feef4a782290f2e34c2
5
5
  SHA512:
6
- metadata.gz: 3a917b2fc75798b3bd5e95416ab8c26f013133c84739f9d58df7bbd687de5b736184d11eae1e604944ba85267f214999f4a552e7beef1b271401e8598841a966
7
- data.tar.gz: abb394a0305a254ce1fda64eba446e49949142f42480e6adf176bf1e62e5cfe6a0280421afbfbefda48bfa3dab31f815891705de4eb1d0d59df2b520575aea93
6
+ metadata.gz: 97c2d1764646f0e7fa90fd7c6d9fd4f3811acde1da0cd110a5f186cd164d52fb61fe2a13add1d75f3fd492ccc4c034e63167a4f1c7f06e8586363b95a58788db
7
+ data.tar.gz: 64c6671f0cddbcdcc71e34ceb4719132f9e503a9e5be9ec73692348b3d023c3b68f572bba05489220dda5eea9f4a4fb89a3559f16d416eb19e6150bf86482640
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## v6.21.0 (23 June 2021)
5
+
6
+ ### Enhancements
7
+
8
+ * Allow a `Method` or any object responding to `#call` to be used as an `on_error` callback or middleware
9
+ | [#662](https://github.com/bugsnag/bugsnag-ruby/pull/662)
10
+ | [odlp](https://github.com/odlp)
11
+
12
+ ### Fixes
13
+
14
+ * Deliver when an error is raised in the block argument to `notify`
15
+ | [#660](https://github.com/bugsnag/bugsnag-ruby/pull/660)
16
+ | [aki77](https://github.com/aki77)
17
+ * Fix potential `NoMethodError` in `Bugsnag::Railtie` when using `require: false` in a Gemfile
18
+ | [#666](https://github.com/bugsnag/bugsnag-ruby/pull/666)
19
+
4
20
  ## v6.20.0 (29 March 2021)
5
21
 
6
22
  ### Enhancements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.20.0
1
+ 6.21.0
data/lib/bugsnag.rb CHANGED
@@ -79,7 +79,12 @@ module Bugsnag
79
79
  report = Report.new(exception, configuration, auto_notify)
80
80
 
81
81
  # If this is an auto_notify we yield the block before the any middleware is run
82
- yield(report) if block_given? && auto_notify
82
+ begin
83
+ yield(report) if block_given? && auto_notify
84
+ rescue StandardError => e
85
+ configuration.warn("Error in internal notify block: #{e}")
86
+ configuration.warn("Error in internal notify block stacktrace: #{e.backtrace.inspect}")
87
+ end
83
88
 
84
89
  if report.ignore?
85
90
  configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in auto_notify block")
@@ -106,7 +111,12 @@ module Bugsnag
106
111
 
107
112
  # If this is not an auto_notify then the block was provided by the user. This should be the last
108
113
  # block that is run as it is the users "most specific" block.
109
- yield(report) if block_given? && !auto_notify
114
+ begin
115
+ yield(report) if block_given? && !auto_notify
116
+ rescue StandardError => e
117
+ configuration.warn("Error in notify block: #{e}")
118
+ configuration.warn("Error in notify block stacktrace: #{e.backtrace.inspect}")
119
+ end
110
120
 
111
121
  if report.ignore?
112
122
  configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in user provided block")
@@ -265,7 +275,7 @@ module Bugsnag
265
275
  # Returning false from an on_error callback will cause the error to be ignored
266
276
  # and will prevent any remaining callbacks from being called
267
277
  #
268
- # @param callback [Proc]
278
+ # @param callback [Proc, Method, #call]
269
279
  # @return [void]
270
280
  def add_on_error(callback)
271
281
  configuration.add_on_error(callback)
@@ -485,7 +485,7 @@ module Bugsnag
485
485
  # Returning false from an on_error callback will cause the error to be ignored
486
486
  # and will prevent any remaining callbacks from being called
487
487
  #
488
- # @param callback [Proc]
488
+ # @param callback [Proc, Method, #call]
489
489
  # @return [void]
490
490
  def add_on_error(callback)
491
491
  middleware.use(callback)
@@ -494,10 +494,10 @@ module Bugsnag
494
494
  ##
495
495
  # Remove the given callback from the list of on_error callbacks
496
496
  #
497
- # Note that this must be the same Proc instance that was passed to
497
+ # Note that this must be the same instance that was passed to
498
498
  # {#add_on_error}, otherwise it will not be removed
499
499
  #
500
- # @param callback [Proc]
500
+ # @param callback [Proc, Method, #call]
501
501
  # @return [void]
502
502
  def remove_on_error(callback)
503
503
  middleware.remove(callback)
@@ -9,11 +9,44 @@ require "bugsnag/integrations/rails/rails_breadcrumbs"
9
9
 
10
10
  module Bugsnag
11
11
  class Railtie < ::Rails::Railtie
12
-
13
12
  FRAMEWORK_ATTRIBUTES = {
14
13
  :framework => "Rails"
15
14
  }
16
15
 
16
+ ##
17
+ # Subscribes to an ActiveSupport event, leaving a breadcrumb when it triggers
18
+ #
19
+ # @api private
20
+ # @param event [Hash] details of the event to subscribe to
21
+ def event_subscription(event)
22
+ ActiveSupport::Notifications.subscribe(event[:id]) do |*, event_id, data|
23
+ filtered_data = data.slice(*event[:allowed_data])
24
+ filtered_data[:event_name] = event[:id]
25
+ filtered_data[:event_id] = event_id
26
+
27
+ if event[:id] == "sql.active_record"
28
+ if data.key?(:binds)
29
+ binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) }
30
+ filtered_data[:binds] = JSON.dump(binds) unless binds.empty?
31
+ end
32
+
33
+ # Rails < 6.1 included connection_id in the event data, but now
34
+ # includes the connection object instead
35
+ if data.key?(:connection) && !data.key?(:connection_id)
36
+ # the connection ID is the object_id of the connection object
37
+ filtered_data[:connection_id] = data[:connection].object_id
38
+ end
39
+ end
40
+
41
+ Bugsnag.leave_breadcrumb(
42
+ event[:message],
43
+ filtered_data,
44
+ event[:type],
45
+ :auto
46
+ )
47
+ end
48
+ end
49
+
17
50
  rake_tasks do
18
51
  require "bugsnag/integrations/rake"
19
52
  load "bugsnag/tasks/bugsnag.rake"
@@ -80,39 +113,5 @@ module Bugsnag
80
113
  Bugsnag.configuration.warn("Unable to add Bugsnag::Rack middleware as the middleware stack is frozen")
81
114
  end
82
115
  end
83
-
84
- ##
85
- # Subscribes to an ActiveSupport event, leaving a breadcrumb when it triggers
86
- #
87
- # @api private
88
- # @param event [Hash] details of the event to subscribe to
89
- def event_subscription(event)
90
- ActiveSupport::Notifications.subscribe(event[:id]) do |*, event_id, data|
91
- filtered_data = data.slice(*event[:allowed_data])
92
- filtered_data[:event_name] = event[:id]
93
- filtered_data[:event_id] = event_id
94
-
95
- if event[:id] == "sql.active_record"
96
- if data.key?(:binds)
97
- binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) }
98
- filtered_data[:binds] = JSON.dump(binds) unless binds.empty?
99
- end
100
-
101
- # Rails < 6.1 included connection_id in the event data, but now
102
- # includes the connection object instead
103
- if data.key?(:connection) && !data.key?(:connection_id)
104
- # the connection ID is the object_id of the connection object
105
- filtered_data[:connection_id] = data[:connection].object_id
106
- end
107
- end
108
-
109
- Bugsnag.leave_breadcrumb(
110
- event[:message],
111
- filtered_data,
112
- event[:type],
113
- :auto
114
- )
115
- end
116
- end
117
116
  end
118
117
  end
@@ -131,8 +131,8 @@ module Bugsnag
131
131
  #
132
132
  # @return [Array<Proc>]
133
133
  def middleware_procs
134
- # Split the middleware into separate lists of Procs and Classes
135
- procs, classes = @middlewares.partition {|middleware| middleware.is_a?(Proc) }
134
+ # Split the middleware into separate lists of callables (e.g. Proc, Lambda, Method) and Classes
135
+ callables, classes = @middlewares.partition {|middleware| middleware.respond_to?(:call) }
136
136
 
137
137
  # Wrap the classes in a proc that, when called, news up the middleware and
138
138
  # passes the next middleware in the queue
@@ -140,12 +140,12 @@ module Bugsnag
140
140
  proc {|next_middleware| middleware.new(next_middleware) }
141
141
  end
142
142
 
143
- # Wrap the list of procs in a proc that, when called, wraps them in an
143
+ # Wrap the list of callables in a proc that, when called, wraps them in an
144
144
  # 'OnErrorCallbacks' instance that also has a reference to the next middleware
145
- wrapped_procs = proc {|next_middleware| OnErrorCallbacks.new(next_middleware, procs) }
145
+ wrapped_callables = proc {|next_middleware| OnErrorCallbacks.new(next_middleware, callables) }
146
146
 
147
- # Return the combined middleware and wrapped procs
148
- middleware_instances.push(wrapped_procs)
147
+ # Return the combined middleware and wrapped callables
148
+ middleware_instances.push(wrapped_callables)
149
149
  end
150
150
  end
151
151
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.20.0
4
+ version: 6.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby