bugsnag 6.19.0 → 6.23.0
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 +99 -0
- data/VERSION +1 -1
- data/lib/bugsnag/breadcrumb_type.rb +14 -0
- data/lib/bugsnag/breadcrumbs/breadcrumb.rb +34 -1
- data/lib/bugsnag/breadcrumbs/breadcrumbs.rb +1 -0
- data/lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb +50 -0
- data/lib/bugsnag/configuration.rb +118 -8
- data/lib/bugsnag/delivery/synchronous.rb +2 -2
- data/lib/bugsnag/delivery/thread_queue.rb +2 -2
- data/lib/bugsnag/error.rb +25 -0
- data/lib/bugsnag/event.rb +7 -0
- data/lib/bugsnag/integrations/mongo.rb +5 -3
- data/lib/bugsnag/integrations/rack.rb +3 -3
- data/lib/bugsnag/integrations/rails/active_job.rb +102 -0
- data/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb +2 -0
- data/lib/bugsnag/integrations/railtie.rb +43 -25
- data/lib/bugsnag/integrations/resque.rb +13 -3
- data/lib/bugsnag/middleware/active_job.rb +18 -0
- data/lib/bugsnag/middleware/classify_error.rb +1 -0
- data/lib/bugsnag/middleware/delayed_job.rb +21 -2
- data/lib/bugsnag/middleware/exception_meta_data.rb +2 -0
- data/lib/bugsnag/middleware/rack_request.rb +2 -2
- data/lib/bugsnag/middleware/rails3_request.rb +2 -2
- data/lib/bugsnag/middleware/rake.rb +1 -1
- data/lib/bugsnag/middleware/sidekiq.rb +1 -1
- data/lib/bugsnag/middleware_stack.rb +6 -6
- data/lib/bugsnag/report.rb +129 -5
- data/lib/bugsnag/session_tracker.rb +3 -7
- data/lib/bugsnag/tasks/bugsnag.rake +1 -1
- data/lib/bugsnag/utility/metadata_delegate.rb +102 -0
- data/lib/bugsnag.rb +61 -5
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 763fc185ada81aaefdfb19edc7ca88788921c4577ec3e5a76addadcd8e13227c
|
4
|
+
data.tar.gz: 47661582b92e719b81f9023678dac8fcd558dd641ae124e0305b3f32157ccdd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de707cdf88e2c4d46cbfcd6fde2dad857c584c366788ea31dffa0b62c80d9a8dea9e8cf030306f70e793bff3999b92ae5c165309eb48d4fab2d77453160cd33
|
7
|
+
data.tar.gz: f23a0d06302491091fc15d209bd09e45f1a47017467f163e1ea36fd4702dbadf1c395e36fb71283261d78c505dc6f2459ad7a7da9052989f81200f6df3c0b7ba
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,105 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
## v6.23.0 (21 September 2021)
|
5
|
+
|
6
|
+
### Enhancements
|
7
|
+
|
8
|
+
* Sessions will now be delivered every 10 seconds, instead of every 30 seconds
|
9
|
+
| [#680](https://github.com/bugsnag/bugsnag-ruby/pull/680)
|
10
|
+
* Log errors that prevent delivery at `ERROR` level
|
11
|
+
| [#681](https://github.com/bugsnag/bugsnag-ruby/pull/681)
|
12
|
+
* Add `on_breadcrumb` callbacks to replace `before_breadcrumb_callbacks`
|
13
|
+
| [#686](https://github.com/bugsnag/bugsnag-ruby/pull/686)
|
14
|
+
* Add `context` attribute to configuration, which will be used as the default context for events. Using this option will disable automatic context setting
|
15
|
+
| [#687](https://github.com/bugsnag/bugsnag-ruby/pull/687)
|
16
|
+
| [#688](https://github.com/bugsnag/bugsnag-ruby/pull/688)
|
17
|
+
* Add `Bugsnag#breadcrumbs` getter to fetch the current list of breadcrumbs
|
18
|
+
| [#689](https://github.com/bugsnag/bugsnag-ruby/pull/689)
|
19
|
+
* Add `time` (an ISO8601 string in UTC) to `device` metadata
|
20
|
+
| [#690](https://github.com/bugsnag/bugsnag-ruby/pull/690)
|
21
|
+
* Add `errors` to `Report`/`Event` containing an array of `Error` objects. The `Error` object contains `error_class`, `error_message`, `stacktrace` and `type` (always "ruby")
|
22
|
+
| [#691](https://github.com/bugsnag/bugsnag-ruby/pull/691)
|
23
|
+
* Add `original_error` to `Report`/`Event` containing the original Exception instance
|
24
|
+
| [#692](https://github.com/bugsnag/bugsnag-ruby/pull/692)
|
25
|
+
* Add `request` to `Report`/`Event` containing HTTP request metadata
|
26
|
+
| [#693](https://github.com/bugsnag/bugsnag-ruby/pull/693)
|
27
|
+
* Add `add_metadata` and `clear_metadata` to `Report`/`Event`
|
28
|
+
| [#694](https://github.com/bugsnag/bugsnag-ruby/pull/694)
|
29
|
+
* Add `set_user` to `Report`/`Event`
|
30
|
+
| [#695](https://github.com/bugsnag/bugsnag-ruby/pull/695)
|
31
|
+
|
32
|
+
### Fixes
|
33
|
+
|
34
|
+
* Avoid starting session delivery thread when the current release stage is not enabled
|
35
|
+
| [#677](https://github.com/bugsnag/bugsnag-ruby/pull/677)
|
36
|
+
|
37
|
+
### Deprecated
|
38
|
+
|
39
|
+
* `before_breadcrumb_callbacks` have been deprecated in favour of `on_breadcrumb` callbacks and will be removed in the next major release
|
40
|
+
* For consistency with Bugsnag notifiers for other languages, a number of methods have been deprecated in this release. The old options will be removed in the next major version | [#676](https://github.com/bugsnag/bugsnag-ruby/pull/676)
|
41
|
+
* The `notify_release_stages` configuration option has been deprecated in favour of `enabled_release_stages`
|
42
|
+
* The `auto_capture_sessions` and `track_sessions` configuration options have been deprecated in favour of `auto_track_sessions`
|
43
|
+
* The `enabled_automatic_breadcrumb_types` configuration option has been deprecated in favour of `enabled_breadcrumb_types`
|
44
|
+
* The `Report` class has been deprecated in favour of the `Event` class
|
45
|
+
* The `Report#meta_data` attribute has been deprecated in favour of `Event#metadata`
|
46
|
+
* The `Breadcrumb#meta_data` attribute has been deprecated in favour of `Breadcrumb#metadata`
|
47
|
+
* The `Breadcrumb#name` attribute has been deprecated in favour of `Breadcrumb#message`
|
48
|
+
* The breadcrumb type constants in the `Bugsnag::Breadcrumbs` module has been deprecated in favour of the constants available in the `Bugsnag::BreadcrumbType` module
|
49
|
+
For example, `Bugsnag::Breadcrumbs::ERROR_BREADCRUMB_TYPE` is now available as `Bugsnag::BreadcrumbType::ERROR`
|
50
|
+
* `Report#exceptions` has been deprecated in favour of the new `errors` property
|
51
|
+
* `Report#raw_exceptions` has been deprecated in favour of the new `original_error` property
|
52
|
+
* Accessing request data via `Report#metadata` has been deprecated in favour of using the new `request` property. Request data will be moved out of metadata in the next major version
|
53
|
+
* The `Report#add_tab` and `Report#remove_tab` methods have been deprecated in favour of the new `add_metadata` and `clear_metadata` methods
|
54
|
+
|
55
|
+
## v6.22.1 (11 August 2021)
|
56
|
+
|
57
|
+
### Fixes
|
58
|
+
|
59
|
+
* Fix possible `LocalJumpError` introduced in v6.22.0
|
60
|
+
| [#675](https://github.com/bugsnag/bugsnag-ruby/pull/675)
|
61
|
+
|
62
|
+
## v6.22.0 (10 August 2021)
|
63
|
+
|
64
|
+
### Enhancements
|
65
|
+
|
66
|
+
* Add support for tracking exceptions and capturing metadata in Active Job, when not using an existing integration
|
67
|
+
| [#670](https://github.com/bugsnag/bugsnag-ruby/pull/670)
|
68
|
+
|
69
|
+
* Improve the report context when using Delayed Job or Resque as the Active Job queue adapter
|
70
|
+
| [#671](https://github.com/bugsnag/bugsnag-ruby/pull/671)
|
71
|
+
|
72
|
+
## v6.21.0 (23 June 2021)
|
73
|
+
|
74
|
+
### Enhancements
|
75
|
+
|
76
|
+
* Allow a `Method` or any object responding to `#call` to be used as an `on_error` callback or middleware
|
77
|
+
| [#662](https://github.com/bugsnag/bugsnag-ruby/pull/662)
|
78
|
+
| [odlp](https://github.com/odlp)
|
79
|
+
|
80
|
+
### Fixes
|
81
|
+
|
82
|
+
* Deliver when an error is raised in the block argument to `notify`
|
83
|
+
| [#660](https://github.com/bugsnag/bugsnag-ruby/pull/660)
|
84
|
+
| [aki77](https://github.com/aki77)
|
85
|
+
* Fix potential `NoMethodError` in `Bugsnag::Railtie` when using `require: false` in a Gemfile
|
86
|
+
| [#666](https://github.com/bugsnag/bugsnag-ruby/pull/666)
|
87
|
+
|
88
|
+
## v6.20.0 (29 March 2021)
|
89
|
+
|
90
|
+
### Enhancements
|
91
|
+
|
92
|
+
* Classify `ActionDispatch::Http::MimeNegotiation::InvalidType` as info severity level
|
93
|
+
| [#654](https://github.com/bugsnag/bugsnag-ruby/pull/654)
|
94
|
+
|
95
|
+
### Fixes
|
96
|
+
|
97
|
+
* Include `connection_id` in ActiveRecord breadcrumb metadata on new versons of Rails
|
98
|
+
| [#655](https://github.com/bugsnag/bugsnag-ruby/pull/655)
|
99
|
+
* Avoid crash when Mongo 1.12 or earlier is used
|
100
|
+
| [#652](https://github.com/bugsnag/bugsnag-ruby/pull/652)
|
101
|
+
| [isabanin](https://github.com/isabanin)
|
102
|
+
|
4
103
|
## 6.19.0 (6 January 2021)
|
5
104
|
|
6
105
|
### Enhancements
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.23.0
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bugsnag/breadcrumbs/breadcrumbs"
|
2
|
+
|
3
|
+
module Bugsnag
|
4
|
+
module BreadcrumbType
|
5
|
+
ERROR = Bugsnag::Breadcrumbs::ERROR_BREADCRUMB_TYPE
|
6
|
+
LOG = Bugsnag::Breadcrumbs::LOG_BREADCRUMB_TYPE
|
7
|
+
MANUAL = Bugsnag::Breadcrumbs::MANUAL_BREADCRUMB_TYPE
|
8
|
+
NAVIGATION = Bugsnag::Breadcrumbs::NAVIGATION_BREADCRUMB_TYPE
|
9
|
+
PROCESS = Bugsnag::Breadcrumbs::PROCESS_BREADCRUMB_TYPE
|
10
|
+
REQUEST = Bugsnag::Breadcrumbs::REQUEST_BREADCRUMB_TYPE
|
11
|
+
STATE = Bugsnag::Breadcrumbs::STATE_BREADCRUMB_TYPE
|
12
|
+
USER = Bugsnag::Breadcrumbs::USER_BREADCRUMB_TYPE
|
13
|
+
end
|
14
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Bugsnag::Breadcrumbs
|
2
2
|
class Breadcrumb
|
3
|
+
# @deprecated Use {#message} instead
|
3
4
|
# @return [String] the breadcrumb name
|
4
5
|
attr_accessor :name
|
5
6
|
|
6
7
|
# @return [String] the breadcrumb type
|
7
8
|
attr_accessor :type
|
8
9
|
|
10
|
+
# @deprecated Use {#metadata} instead
|
9
11
|
# @return [Hash, nil] metadata hash containing strings, numbers, or booleans, or nil
|
10
12
|
attr_accessor :meta_data
|
11
13
|
|
@@ -23,7 +25,7 @@ module Bugsnag::Breadcrumbs
|
|
23
25
|
# @api private
|
24
26
|
#
|
25
27
|
# @param name [String] the breadcrumb name
|
26
|
-
# @param type [String] the breadcrumb type from Bugsnag::
|
28
|
+
# @param type [String] the breadcrumb type from Bugsnag::BreadcrumbType
|
27
29
|
# @param meta_data [Hash, nil] a hash containing strings, numbers, or booleans, or nil
|
28
30
|
# @param auto [Symbol] set to `:auto` if the breadcrumb is automatically generated
|
29
31
|
def initialize(name, type, meta_data, auto)
|
@@ -72,5 +74,36 @@ module Bugsnag::Breadcrumbs
|
|
72
74
|
:timestamp => @timestamp.iso8601(3)
|
73
75
|
}
|
74
76
|
end
|
77
|
+
|
78
|
+
# TODO: "message" and "metadata" can be simple attr_accessors when they
|
79
|
+
# replace "name" and "meta_data"
|
80
|
+
# NOTE: these are not aliases as YARD doesn't allow documenting the non-alias
|
81
|
+
# as deprecated without also marking the alias as deprecated
|
82
|
+
|
83
|
+
# The breadcrumb message
|
84
|
+
# @!attribute message
|
85
|
+
# @return [String]
|
86
|
+
def message
|
87
|
+
@name
|
88
|
+
end
|
89
|
+
|
90
|
+
# @param message [String]
|
91
|
+
# @return [void]
|
92
|
+
def message=(message)
|
93
|
+
@name = message
|
94
|
+
end
|
95
|
+
|
96
|
+
# A Hash containing arbitrary metadata associated with this breadcrumb
|
97
|
+
# @!attribute metadata
|
98
|
+
# @return [Hash, nil]
|
99
|
+
def metadata
|
100
|
+
@meta_data
|
101
|
+
end
|
102
|
+
|
103
|
+
# @param metadata [Hash, nil]
|
104
|
+
# @return [void]
|
105
|
+
def metadata=(metadata)
|
106
|
+
@meta_data = metadata
|
107
|
+
end
|
75
108
|
end
|
76
109
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
module Bugsnag::Breadcrumbs
|
4
|
+
class OnBreadcrumbCallbackList
|
5
|
+
def initialize(configuration)
|
6
|
+
@callbacks = Set.new
|
7
|
+
@mutex = Mutex.new
|
8
|
+
@configuration = configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
##
|
12
|
+
# @param callback [Proc, Method, #call]
|
13
|
+
# @return [void]
|
14
|
+
def add(callback)
|
15
|
+
@mutex.synchronize do
|
16
|
+
@callbacks.add(callback)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# @param callback [Proc, Method, #call]
|
22
|
+
# @return [void]
|
23
|
+
def remove(callback)
|
24
|
+
@mutex.synchronize do
|
25
|
+
@callbacks.delete(callback)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# @param breadcrumb [Breadcrumb]
|
31
|
+
# @return [void]
|
32
|
+
def call(breadcrumb)
|
33
|
+
@callbacks.each do |callback|
|
34
|
+
begin
|
35
|
+
should_continue = callback.call(breadcrumb)
|
36
|
+
rescue StandardError => e
|
37
|
+
@configuration.warn("Error occurred in on_breadcrumb callback: '#{e}'")
|
38
|
+
@configuration.warn("on_breadcrumb callback stacktrace: #{e.backtrace.inspect}")
|
39
|
+
end
|
40
|
+
|
41
|
+
# only stop if should_continue is explicity 'false' to allow callbacks
|
42
|
+
# to return 'nil'
|
43
|
+
if should_continue == false
|
44
|
+
breadcrumb.ignore!
|
45
|
+
break
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -12,6 +12,7 @@ require "bugsnag/middleware/session_data"
|
|
12
12
|
require "bugsnag/middleware/breadcrumbs"
|
13
13
|
require "bugsnag/utility/circular_buffer"
|
14
14
|
require "bugsnag/breadcrumbs/breadcrumbs"
|
15
|
+
require "bugsnag/breadcrumbs/on_breadcrumb_callback_list"
|
15
16
|
|
16
17
|
module Bugsnag
|
17
18
|
class Configuration
|
@@ -24,6 +25,7 @@ module Bugsnag
|
|
24
25
|
attr_accessor :release_stage
|
25
26
|
|
26
27
|
# A list of which release stages should cause notifications to be sent
|
28
|
+
# @deprecated Use {#enabled_release_stages} instead
|
27
29
|
# @return [Array<String>, nil]
|
28
30
|
attr_accessor :notify_release_stages
|
29
31
|
|
@@ -104,6 +106,7 @@ module Bugsnag
|
|
104
106
|
attr_accessor :discard_classes
|
105
107
|
|
106
108
|
# Whether Bugsnag should automatically record sessions
|
109
|
+
# @deprecated Use {#auto_track_sessions} instead
|
107
110
|
# @return [Boolean]
|
108
111
|
attr_accessor :auto_capture_sessions
|
109
112
|
|
@@ -125,7 +128,8 @@ module Bugsnag
|
|
125
128
|
attr_reader :enable_sessions
|
126
129
|
|
127
130
|
# A list of strings indicating allowable automatic breadcrumb types
|
128
|
-
# @
|
131
|
+
# @deprecated Use {#enabled_breadcrumb_types} instead
|
132
|
+
# @see Bugsnag::BreadcrumbType
|
129
133
|
# @return [Array<String>]
|
130
134
|
attr_accessor :enabled_automatic_breadcrumb_types
|
131
135
|
|
@@ -141,10 +145,20 @@ module Bugsnag
|
|
141
145
|
# @return [Regexp]
|
142
146
|
attr_accessor :vendor_path
|
143
147
|
|
148
|
+
# The default context for all future events
|
149
|
+
# Setting this will disable automatic context setting
|
150
|
+
# @return [String, nil]
|
151
|
+
attr_accessor :context
|
152
|
+
|
144
153
|
# @api private
|
145
154
|
# @return [Array<String>]
|
146
155
|
attr_reader :scopes_to_filter
|
147
156
|
|
157
|
+
# Expose on_breadcrumb_callbacks internally for Bugsnag.leave_breadcrumb
|
158
|
+
# @api private
|
159
|
+
# @return [Breadcrumbs::OnBreadcrumbCallbackList]
|
160
|
+
attr_reader :on_breadcrumb_callbacks
|
161
|
+
|
148
162
|
API_KEY_REGEX = /[0-9a-f]{32}/i
|
149
163
|
THREAD_LOCAL_NAME = "bugsnag_req_data"
|
150
164
|
|
@@ -193,6 +207,7 @@ module Bugsnag
|
|
193
207
|
# All valid breadcrumb types should be allowable initially
|
194
208
|
self.enabled_automatic_breadcrumb_types = Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES.dup
|
195
209
|
self.before_breadcrumb_callbacks = []
|
210
|
+
@on_breadcrumb_callbacks = Breadcrumbs::OnBreadcrumbCallbackList.new(self)
|
196
211
|
|
197
212
|
# Store max_breadcrumbs here instead of outputting breadcrumbs.max_items
|
198
213
|
# to avoid infinite recursion when creating breadcrumb buffer
|
@@ -389,15 +404,23 @@ module Bugsnag
|
|
389
404
|
##
|
390
405
|
# Logs a warning level message
|
391
406
|
#
|
392
|
-
# @param
|
407
|
+
# @param message [String, #to_s] The message to log
|
393
408
|
def warn(message)
|
394
409
|
logger.warn(PROG_NAME) { message }
|
395
410
|
end
|
396
411
|
|
412
|
+
##
|
413
|
+
# Logs an error level message
|
414
|
+
#
|
415
|
+
# @param message [String, #to_s] The message to log
|
416
|
+
def error(message)
|
417
|
+
logger.error(PROG_NAME) { message }
|
418
|
+
end
|
419
|
+
|
397
420
|
##
|
398
421
|
# Logs a debug level message
|
399
422
|
#
|
400
|
-
# @param
|
423
|
+
# @param message [String, #to_s] The message to log
|
401
424
|
def debug(message)
|
402
425
|
logger.debug(PROG_NAME) { message }
|
403
426
|
end
|
@@ -426,9 +449,12 @@ module Bugsnag
|
|
426
449
|
end
|
427
450
|
|
428
451
|
##
|
429
|
-
# Returns the
|
452
|
+
# Returns the current list of breadcrumbs
|
453
|
+
#
|
454
|
+
# This is a per-thread circular buffer, containing at most 'max_breadcrumbs'
|
455
|
+
# breadcrumbs
|
430
456
|
#
|
431
|
-
# @return [Bugsnag::Utility::CircularBuffer]
|
457
|
+
# @return [Bugsnag::Utility::CircularBuffer]
|
432
458
|
def breadcrumbs
|
433
459
|
request_data[:breadcrumbs] ||= Bugsnag::Utility::CircularBuffer.new(@max_breadcrumbs)
|
434
460
|
end
|
@@ -485,7 +511,7 @@ module Bugsnag
|
|
485
511
|
# Returning false from an on_error callback will cause the error to be ignored
|
486
512
|
# and will prevent any remaining callbacks from being called
|
487
513
|
#
|
488
|
-
# @param callback [Proc]
|
514
|
+
# @param callback [Proc, Method, #call]
|
489
515
|
# @return [void]
|
490
516
|
def add_on_error(callback)
|
491
517
|
middleware.use(callback)
|
@@ -494,15 +520,99 @@ module Bugsnag
|
|
494
520
|
##
|
495
521
|
# Remove the given callback from the list of on_error callbacks
|
496
522
|
#
|
497
|
-
# Note that this must be the same
|
523
|
+
# Note that this must be the same instance that was passed to
|
498
524
|
# {#add_on_error}, otherwise it will not be removed
|
499
525
|
#
|
500
|
-
# @param callback [Proc]
|
526
|
+
# @param callback [Proc, Method, #call]
|
501
527
|
# @return [void]
|
502
528
|
def remove_on_error(callback)
|
503
529
|
middleware.remove(callback)
|
504
530
|
end
|
505
531
|
|
532
|
+
##
|
533
|
+
# Add the given callback to the list of on_breadcrumb callbacks
|
534
|
+
#
|
535
|
+
# The on_breadcrumb callbacks will be called when a breadcrumb is left and
|
536
|
+
# are passed the {Breadcrumbs::Breadcrumb Breadcrumb} object
|
537
|
+
#
|
538
|
+
# Returning false from an on_breadcrumb callback will cause the breadcrumb
|
539
|
+
# to be ignored and will prevent any remaining callbacks from being called
|
540
|
+
#
|
541
|
+
# @param callback [Proc, Method, #call]
|
542
|
+
# @return [void]
|
543
|
+
def add_on_breadcrumb(callback)
|
544
|
+
@on_breadcrumb_callbacks.add(callback)
|
545
|
+
end
|
546
|
+
|
547
|
+
##
|
548
|
+
# Remove the given callback from the list of on_breadcrumb callbacks
|
549
|
+
#
|
550
|
+
# Note that this must be the same instance that was passed to
|
551
|
+
# {add_on_breadcrumb}, otherwise it will not be removed
|
552
|
+
#
|
553
|
+
# @param callback [Proc, Method, #call]
|
554
|
+
# @return [void]
|
555
|
+
def remove_on_breadcrumb(callback)
|
556
|
+
@on_breadcrumb_callbacks.remove(callback)
|
557
|
+
end
|
558
|
+
|
559
|
+
##
|
560
|
+
# Has the context been explicitly set?
|
561
|
+
#
|
562
|
+
# This is necessary to differentiate between the context not being set and
|
563
|
+
# the context being set to 'nil' explicitly
|
564
|
+
#
|
565
|
+
# @api private
|
566
|
+
# @return [Boolean]
|
567
|
+
def context_set?
|
568
|
+
defined?(@context) != nil
|
569
|
+
end
|
570
|
+
|
571
|
+
# TODO: These methods can be a simple attr_accessor when they replace the
|
572
|
+
# methods they are aliasing
|
573
|
+
# NOTE: they are not aliases as YARD doesn't allow documenting the non-alias
|
574
|
+
# as deprecated without also marking the alias as deprecated
|
575
|
+
|
576
|
+
# A list of which release stages should cause notifications to be sent
|
577
|
+
# @!attribute enabled_release_stages
|
578
|
+
# @return [Array<String>, nil]
|
579
|
+
def enabled_release_stages
|
580
|
+
@notify_release_stages
|
581
|
+
end
|
582
|
+
|
583
|
+
# @param release_stages [Array<String>, nil]
|
584
|
+
# @return [void]
|
585
|
+
def enabled_release_stages=(release_stages)
|
586
|
+
@notify_release_stages = release_stages
|
587
|
+
end
|
588
|
+
|
589
|
+
# A list of breadcrumb types that Bugsnag will collect automatically
|
590
|
+
# @!attribute enabled_breadcrumb_types
|
591
|
+
# @see Bugsnag::BreadcrumbType
|
592
|
+
# @return [Array<String>]
|
593
|
+
def enabled_breadcrumb_types
|
594
|
+
@enabled_automatic_breadcrumb_types
|
595
|
+
end
|
596
|
+
|
597
|
+
# @param breadcrumb_types [Array<String>]
|
598
|
+
# @return [void]
|
599
|
+
def enabled_breadcrumb_types=(breadcrumb_types)
|
600
|
+
@enabled_automatic_breadcrumb_types = breadcrumb_types
|
601
|
+
end
|
602
|
+
|
603
|
+
# Whether sessions should be tracked automatically
|
604
|
+
# @!attribute auto_track_sessions
|
605
|
+
# @return [Boolean]
|
606
|
+
def auto_track_sessions
|
607
|
+
@auto_capture_sessions
|
608
|
+
end
|
609
|
+
|
610
|
+
# @param track_sessions [Boolean]
|
611
|
+
# @return [void]
|
612
|
+
def auto_track_sessions=(track_sessions)
|
613
|
+
@auto_capture_sessions = track_sessions
|
614
|
+
end
|
615
|
+
|
506
616
|
private
|
507
617
|
|
508
618
|
attr_writer :scopes_to_filter
|
@@ -18,8 +18,8 @@ module Bugsnag
|
|
18
18
|
# KLUDGE: Since we don't re-raise http exceptions, this breaks rspec
|
19
19
|
raise if e.class.to_s == "RSpec::Expectations::ExpectationNotMetError"
|
20
20
|
|
21
|
-
configuration.
|
22
|
-
configuration.
|
21
|
+
configuration.error("Unable to send information to Bugsnag (#{url}), #{e.inspect}")
|
22
|
+
configuration.error(e.backtrace)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -31,8 +31,8 @@ module Bugsnag
|
|
31
31
|
begin
|
32
32
|
payload = get_payload.call
|
33
33
|
rescue StandardError => e
|
34
|
-
configuration.
|
35
|
-
configuration.
|
34
|
+
configuration.error("Unable to send information to Bugsnag (#{url}), #{e.inspect}")
|
35
|
+
configuration.error(e.backtrace)
|
36
36
|
end
|
37
37
|
|
38
38
|
Synchronous.deliver(url, payload, configuration, options) unless payload.nil?
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Bugsnag
|
2
|
+
class Error
|
3
|
+
# @return [String] the error's class name
|
4
|
+
attr_accessor :error_class
|
5
|
+
|
6
|
+
# @return [String] the error's message
|
7
|
+
attr_accessor :error_message
|
8
|
+
|
9
|
+
# @return [Hash] the error's processed stacktrace
|
10
|
+
attr_reader :stacktrace
|
11
|
+
|
12
|
+
# @return [String] the type of error (always "ruby")
|
13
|
+
attr_accessor :type
|
14
|
+
|
15
|
+
# @api private
|
16
|
+
TYPE = "ruby".freeze
|
17
|
+
|
18
|
+
def initialize(error_class, error_message, stacktrace)
|
19
|
+
@error_class = error_class
|
20
|
+
@error_message = error_message
|
21
|
+
@stacktrace = stacktrace
|
22
|
+
@type = TYPE
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -127,6 +127,8 @@ module Bugsnag
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
Mongo
|
130
|
+
if defined?(Mongo::Monitoring)
|
131
|
+
##
|
132
|
+
# Add the subscriber to the global Mongo monitoring object
|
133
|
+
Mongo::Monitoring::Global.subscribe(Mongo::Monitoring::COMMAND, Bugsnag::MongoBreadcrumbSubscriber.new)
|
134
|
+
end
|
@@ -25,9 +25,9 @@ module Bugsnag
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# Hook up rack-based notification middlewares
|
28
|
-
config.
|
29
|
-
config.
|
30
|
-
config.
|
28
|
+
config.internal_middleware.insert_before(Bugsnag::Middleware::Rails3Request, Bugsnag::Middleware::RackRequest) if defined?(::Rack)
|
29
|
+
config.internal_middleware.use(Bugsnag::Middleware::WardenUser) if defined?(Warden)
|
30
|
+
config.internal_middleware.use(Bugsnag::Middleware::ClearanceUser) if defined?(Clearance)
|
31
31
|
|
32
32
|
# Set environment data for payload
|
33
33
|
# Note we only set the detected app_type if it's not already set. This
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Bugsnag::Rails
|
4
|
+
module ActiveJob
|
5
|
+
SEVERITY = 'error'
|
6
|
+
SEVERITY_REASON = {
|
7
|
+
type: Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
|
8
|
+
attributes: { framework: 'Active Job' }
|
9
|
+
}
|
10
|
+
|
11
|
+
EXISTING_INTEGRATIONS = Set[
|
12
|
+
'ActiveJob::QueueAdapters::DelayedJobAdapter',
|
13
|
+
'ActiveJob::QueueAdapters::QueAdapter',
|
14
|
+
'ActiveJob::QueueAdapters::ResqueAdapter',
|
15
|
+
'ActiveJob::QueueAdapters::ShoryukenAdapter',
|
16
|
+
'ActiveJob::QueueAdapters::SidekiqAdapter'
|
17
|
+
]
|
18
|
+
|
19
|
+
INLINE_ADAPTER = 'ActiveJob::QueueAdapters::InlineAdapter'
|
20
|
+
|
21
|
+
# these methods were added after the first Active Job release so
|
22
|
+
# may not be present, depending on the Rails version
|
23
|
+
MAYBE_MISSING_METHODS = [
|
24
|
+
:provider_job_id,
|
25
|
+
:priority,
|
26
|
+
:executions,
|
27
|
+
:enqueued_at,
|
28
|
+
:timezone
|
29
|
+
]
|
30
|
+
|
31
|
+
def self.included(base)
|
32
|
+
base.class_eval do
|
33
|
+
around_perform do |job, block|
|
34
|
+
adapter = _bugsnag_get_adapter_name(job)
|
35
|
+
|
36
|
+
# if we have an integration for this queue adapter already then we should
|
37
|
+
# leave this job alone or we'll end up with duplicate metadata
|
38
|
+
next block.call if EXISTING_INTEGRATIONS.include?(adapter)
|
39
|
+
|
40
|
+
Bugsnag.configuration.detected_app_type = 'active job'
|
41
|
+
|
42
|
+
begin
|
43
|
+
Bugsnag.configuration.set_request_data(:active_job, _bugsnag_extract_metadata(job))
|
44
|
+
|
45
|
+
block.call
|
46
|
+
rescue Exception => e
|
47
|
+
Bugsnag.notify(e, true) do |report|
|
48
|
+
report.severity = SEVERITY
|
49
|
+
report.severity_reason = SEVERITY_REASON
|
50
|
+
end
|
51
|
+
|
52
|
+
# when using the "inline" adapter the job is run immediately, which
|
53
|
+
# will result in our Rack integration catching the re-raised error
|
54
|
+
# and reporting it a second time if it's run in a web request
|
55
|
+
if adapter == INLINE_ADAPTER
|
56
|
+
e.instance_eval do
|
57
|
+
def skip_bugsnag
|
58
|
+
true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
raise
|
64
|
+
ensure
|
65
|
+
Bugsnag.configuration.clear_request_data
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def _bugsnag_get_adapter_name(job)
|
74
|
+
adapter = job.class.queue_adapter
|
75
|
+
|
76
|
+
# in Rails 4 queue adapters were references to a class. In Rails 5+
|
77
|
+
# they are an instance of that class instead
|
78
|
+
return adapter.name if adapter.is_a?(Class)
|
79
|
+
|
80
|
+
adapter.class.name
|
81
|
+
end
|
82
|
+
|
83
|
+
def _bugsnag_extract_metadata(job)
|
84
|
+
metadata = {
|
85
|
+
job_id: job.job_id,
|
86
|
+
job_name: job.class.name,
|
87
|
+
queue: job.queue_name,
|
88
|
+
arguments: job.arguments,
|
89
|
+
locale: job.locale
|
90
|
+
}
|
91
|
+
|
92
|
+
MAYBE_MISSING_METHODS.each do |method_name|
|
93
|
+
next unless job.respond_to?(method_name)
|
94
|
+
|
95
|
+
metadata[method_name] = job.send(method_name)
|
96
|
+
end
|
97
|
+
|
98
|
+
metadata.compact!
|
99
|
+
metadata
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -38,6 +38,8 @@ module Bugsnag::Rails
|
|
38
38
|
:type => Bugsnag::Breadcrumbs::PROCESS_BREADCRUMB_TYPE,
|
39
39
|
:allowed_data => [
|
40
40
|
:name,
|
41
|
+
# :connection_id is no longer provided in Rails 6.1+ but we can get it
|
42
|
+
# from the :connection key of the event instead
|
41
43
|
:connection_id,
|
42
44
|
:cached
|
43
45
|
]
|