bugsnag 6.18.0 → 6.22.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -0
- data/VERSION +1 -1
- data/lib/bugsnag.rb +13 -3
- data/lib/bugsnag/breadcrumbs/validator.rb +0 -22
- data/lib/bugsnag/configuration.rb +3 -3
- data/lib/bugsnag/helpers.rb +15 -2
- 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 +12 -2
- 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_stack.rb +6 -6
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a06ee3b5502be46d703f258c7bda2a5fca647fbe210095e989dd069af901a78
|
4
|
+
data.tar.gz: 622e923de05d81c2d15fe65d738e7191e75b84230c0bbdcb8fed7c9f6831057c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ea25266b534f698108e3bc1cbbfeb81d6b528b77653ffe8edce45b7d6d0309faba4a43f0aeb946ace35b84b738cdd275e12cdc998abc7c2b20c02fa2ea07ed4
|
7
|
+
data.tar.gz: 96a1fe53d1f2167cc3458e53ec178e6c8c25fbde85d1dca17a329da85f9ebde4e72416b5930f9ed595955c48e043e22d60915483e163d0f274a4292a06fa70d8
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,65 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
## v6.22.1 (11 August 2021)
|
5
|
+
|
6
|
+
### Fixes
|
7
|
+
|
8
|
+
* Fix possible `LocalJumpError` introduced in v6.22.0
|
9
|
+
| [#675](https://github.com/bugsnag/bugsnag-ruby/pull/675)
|
10
|
+
|
11
|
+
## v6.22.0 (10 August 2021)
|
12
|
+
|
13
|
+
### Enhancements
|
14
|
+
|
15
|
+
* Add support for tracking exceptions and capturing metadata in Active Job, when not using an existing integration
|
16
|
+
| [#670](https://github.com/bugsnag/bugsnag-ruby/pull/670)
|
17
|
+
|
18
|
+
* Improve the report context when using Delayed Job or Resque as the Active Job queue adapter
|
19
|
+
| [#671](https://github.com/bugsnag/bugsnag-ruby/pull/671)
|
20
|
+
|
21
|
+
## v6.21.0 (23 June 2021)
|
22
|
+
|
23
|
+
### Enhancements
|
24
|
+
|
25
|
+
* Allow a `Method` or any object responding to `#call` to be used as an `on_error` callback or middleware
|
26
|
+
| [#662](https://github.com/bugsnag/bugsnag-ruby/pull/662)
|
27
|
+
| [odlp](https://github.com/odlp)
|
28
|
+
|
29
|
+
### Fixes
|
30
|
+
|
31
|
+
* Deliver when an error is raised in the block argument to `notify`
|
32
|
+
| [#660](https://github.com/bugsnag/bugsnag-ruby/pull/660)
|
33
|
+
| [aki77](https://github.com/aki77)
|
34
|
+
* Fix potential `NoMethodError` in `Bugsnag::Railtie` when using `require: false` in a Gemfile
|
35
|
+
| [#666](https://github.com/bugsnag/bugsnag-ruby/pull/666)
|
36
|
+
|
37
|
+
## v6.20.0 (29 March 2021)
|
38
|
+
|
39
|
+
### Enhancements
|
40
|
+
|
41
|
+
* Classify `ActionDispatch::Http::MimeNegotiation::InvalidType` as info severity level
|
42
|
+
| [#654](https://github.com/bugsnag/bugsnag-ruby/pull/654)
|
43
|
+
|
44
|
+
### Fixes
|
45
|
+
|
46
|
+
* Include `connection_id` in ActiveRecord breadcrumb metadata on new versons of Rails
|
47
|
+
| [#655](https://github.com/bugsnag/bugsnag-ruby/pull/655)
|
48
|
+
* Avoid crash when Mongo 1.12 or earlier is used
|
49
|
+
| [#652](https://github.com/bugsnag/bugsnag-ruby/pull/652)
|
50
|
+
| [isabanin](https://github.com/isabanin)
|
51
|
+
|
52
|
+
## 6.19.0 (6 January 2021)
|
53
|
+
|
54
|
+
### Enhancements
|
55
|
+
|
56
|
+
* Exception messages will be truncated if they have a length greater than 3,072
|
57
|
+
| [#636](https://github.com/bugsnag/bugsnag-ruby/pull/636)
|
58
|
+
| [joshuapinter](https://github.com/joshuapinter)
|
59
|
+
|
60
|
+
* Breadcrumb metadata can now contain any type
|
61
|
+
| [#648](https://github.com/bugsnag/bugsnag-ruby/pull/648)
|
62
|
+
|
4
63
|
## 6.18.0 (27 October 2020)
|
5
64
|
|
6
65
|
### Enhancements
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.22.1
|
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
|
-
|
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
|
-
|
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)
|
@@ -15,16 +15,6 @@ module Bugsnag::Breadcrumbs
|
|
15
15
|
#
|
16
16
|
# @param breadcrumb [Bugsnag::Breadcrumbs::Breadcrumb] the breadcrumb to be validated
|
17
17
|
def validate(breadcrumb)
|
18
|
-
# Check meta_data hash doesn't contain complex values
|
19
|
-
breadcrumb.meta_data = breadcrumb.meta_data.select do |k, v|
|
20
|
-
if valid_meta_data_type?(v)
|
21
|
-
true
|
22
|
-
else
|
23
|
-
@configuration.debug("Breadcrumb #{breadcrumb.name} meta_data #{k}:#{v.class} has been dropped for having an invalid data type")
|
24
|
-
false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
18
|
# Check type is valid, set to manual otherwise
|
29
19
|
unless Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES.include?(breadcrumb.type)
|
30
20
|
@configuration.debug("Invalid type: #{breadcrumb.type} for breadcrumb: #{breadcrumb.name}, defaulting to #{Bugsnag::Breadcrumbs::MANUAL_BREADCRUMB_TYPE}")
|
@@ -37,17 +27,5 @@ module Bugsnag::Breadcrumbs
|
|
37
27
|
@configuration.debug("Automatic breadcrumb of type #{breadcrumb.type} ignored: #{breadcrumb.name}")
|
38
28
|
breadcrumb.ignore!
|
39
29
|
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
##
|
44
|
-
# Tests whether the meta_data types are non-complex objects.
|
45
|
-
#
|
46
|
-
# Acceptable types are String, Symbol, Numeric, TrueClass, FalseClass, and nil.
|
47
|
-
#
|
48
|
-
# @param value [Object] the object to be type checked
|
49
|
-
def valid_meta_data_type?(value)
|
50
|
-
value.nil? || value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(Numeric) || value.is_a?(FalseClass) || value.is_a?(TrueClass)
|
51
|
-
end
|
52
30
|
end
|
53
31
|
end
|
@@ -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
|
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)
|
data/lib/bugsnag/helpers.rb
CHANGED
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
|
5
5
|
|
6
6
|
module Bugsnag
|
7
|
-
module Helpers
|
7
|
+
module Helpers # rubocop:todo Metrics/ModuleLength
|
8
8
|
MAX_STRING_LENGTH = 3072
|
9
9
|
MAX_PAYLOAD_LENGTH = 512000
|
10
10
|
MAX_ARRAY_LENGTH = 80
|
@@ -19,8 +19,12 @@ module Bugsnag
|
|
19
19
|
|
20
20
|
return value unless payload_too_long?(value)
|
21
21
|
|
22
|
+
# Truncate exception messages
|
23
|
+
reduced_value = truncate_exception_messages(value)
|
24
|
+
return reduced_value unless payload_too_long?(reduced_value)
|
25
|
+
|
22
26
|
# Trim metadata
|
23
|
-
reduced_value = trim_metadata(
|
27
|
+
reduced_value = trim_metadata(reduced_value)
|
24
28
|
return reduced_value unless payload_too_long?(reduced_value)
|
25
29
|
|
26
30
|
# Trim code from stacktrace
|
@@ -71,6 +75,15 @@ module Bugsnag
|
|
71
75
|
|
72
76
|
TRUNCATION_INFO = '[TRUNCATED]'
|
73
77
|
|
78
|
+
##
|
79
|
+
# Truncate exception messages
|
80
|
+
def self.truncate_exception_messages(payload)
|
81
|
+
extract_exception(payload) do |exception|
|
82
|
+
exception[:message] = trim_as_string(exception[:message])
|
83
|
+
end
|
84
|
+
payload
|
85
|
+
end
|
86
|
+
|
74
87
|
##
|
75
88
|
# Remove all code from stacktraces
|
76
89
|
def self.trim_stacktrace_code(payload)
|
@@ -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
|
]
|
@@ -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"
|
@@ -27,7 +60,7 @@ module Bugsnag
|
|
27
60
|
config.logger = ::Rails.logger
|
28
61
|
config.release_stage ||= ::Rails.env.to_s
|
29
62
|
config.project_root = ::Rails.root.to_s
|
30
|
-
config.
|
63
|
+
config.internal_middleware.use(Bugsnag::Middleware::Rails3Request)
|
31
64
|
config.runtime_versions["rails"] = ::Rails::VERSION::STRING
|
32
65
|
end
|
33
66
|
|
@@ -41,6 +74,14 @@ module Bugsnag
|
|
41
74
|
include Bugsnag::Rails::ActiveRecordRescue
|
42
75
|
end
|
43
76
|
|
77
|
+
ActiveSupport.on_load(:active_job) do
|
78
|
+
require "bugsnag/middleware/active_job"
|
79
|
+
Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::ActiveJob)
|
80
|
+
|
81
|
+
require "bugsnag/integrations/rails/active_job"
|
82
|
+
include Bugsnag::Rails::ActiveJob
|
83
|
+
end
|
84
|
+
|
44
85
|
Bugsnag::Rails::DEFAULT_RAILS_BREADCRUMBS.each { |event| event_subscription(event) }
|
45
86
|
|
46
87
|
# Make sure we don't overwrite the value set by another integration because
|
@@ -80,28 +121,5 @@ module Bugsnag
|
|
80
121
|
Bugsnag.configuration.warn("Unable to add Bugsnag::Rack middleware as the middleware stack is frozen")
|
81
122
|
end
|
82
123
|
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
|
-
if event[:id] == "sql.active_record" && data.key?(:binds)
|
95
|
-
binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) }
|
96
|
-
filtered_data[:binds] = JSON.dump(binds) unless binds.empty?
|
97
|
-
end
|
98
|
-
Bugsnag.leave_breadcrumb(
|
99
|
-
event[:message],
|
100
|
-
filtered_data,
|
101
|
-
event[:type],
|
102
|
-
:auto
|
103
|
-
)
|
104
|
-
end
|
105
|
-
end
|
106
124
|
end
|
107
125
|
end
|
@@ -44,8 +44,18 @@ module Bugsnag
|
|
44
44
|
:attributes => FRAMEWORK_ATTRIBUTES
|
45
45
|
}
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
metadata = payload
|
48
|
+
class_name = payload['class']
|
49
|
+
|
50
|
+
# when using Active Job the payload "class" will always be the Resque
|
51
|
+
# "JobWrapper", not the actual job class so we need to fix this here
|
52
|
+
if metadata['args'] && metadata['args'][0] && metadata['args'][0]['job_class']
|
53
|
+
class_name = metadata['args'][0]['job_class']
|
54
|
+
metadata['wrapped'] ||= class_name
|
55
|
+
end
|
56
|
+
|
57
|
+
context = "#{class_name}@#{queue}"
|
58
|
+
report.meta_data.merge!({ context: context, payload: metadata })
|
49
59
|
report.context = context
|
50
60
|
end
|
51
61
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Bugsnag::Middleware
|
2
|
+
class ActiveJob
|
3
|
+
def initialize(bugsnag)
|
4
|
+
@bugsnag = bugsnag
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(report)
|
8
|
+
data = report.request_data[:active_job]
|
9
|
+
|
10
|
+
if data
|
11
|
+
report.add_tab(:active_job, data)
|
12
|
+
report.context = "#{data[:job_name]}@#{data[:queue]}"
|
13
|
+
end
|
14
|
+
|
15
|
+
@bugsnag.call(report)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -9,6 +9,7 @@ module Bugsnag::Middleware
|
|
9
9
|
"ActionController::UnknownAction",
|
10
10
|
"ActionController::UnknownFormat",
|
11
11
|
"ActionController::UnknownHttpMethod",
|
12
|
+
"ActionDispatch::Http::MimeNegotiation::InvalidType",
|
12
13
|
"ActiveRecord::RecordNotFound",
|
13
14
|
"CGI::Session::CookieStore::TamperedWithCookie",
|
14
15
|
"Mongoid::Errors::DocumentNotFound",
|
@@ -2,6 +2,11 @@ module Bugsnag::Middleware
|
|
2
2
|
##
|
3
3
|
# Attaches delayed_job information to an error report
|
4
4
|
class DelayedJob
|
5
|
+
# Active Job's queue adapter sets the "display_name" to this format. This
|
6
|
+
# breaks the event context as the ID and arguments are included, which will
|
7
|
+
# differ between executions of the same job
|
8
|
+
ACTIVE_JOB_DISPLAY_NAME = /^.* \[[0-9a-f-]+\] from DelayedJob\(.*\) with arguments: \[.*\]$/
|
9
|
+
|
5
10
|
def initialize(bugsnag)
|
6
11
|
@bugsnag = bugsnag
|
7
12
|
end
|
@@ -23,8 +28,10 @@ module Bugsnag::Middleware
|
|
23
28
|
if job.respond_to?(:payload_object)
|
24
29
|
job_data[:active_job] = job.payload_object.job_data if job.payload_object.respond_to?(:job_data)
|
25
30
|
payload_data = construct_job_payload(job.payload_object)
|
26
|
-
|
27
|
-
|
31
|
+
|
32
|
+
context = get_context(payload_data, job_data[:active_job])
|
33
|
+
report.context = context unless context.nil?
|
34
|
+
|
28
35
|
job_data[:payload] = payload_data
|
29
36
|
end
|
30
37
|
|
@@ -70,5 +77,17 @@ module Bugsnag::Middleware
|
|
70
77
|
end
|
71
78
|
data
|
72
79
|
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def get_context(payload_data, active_job_data)
|
84
|
+
if payload_data.include?(:display_name) && !ACTIVE_JOB_DISPLAY_NAME.match?(payload_data[:display_name])
|
85
|
+
payload_data[:display_name]
|
86
|
+
elsif active_job_data && active_job_data['job_class'] && active_job_data['queue_name']
|
87
|
+
"#{active_job_data['job_class']}@#{active_job_data['queue_name']}"
|
88
|
+
elsif payload_data.include?(:class)
|
89
|
+
payload_data[:class]
|
90
|
+
end
|
91
|
+
end
|
73
92
|
end
|
74
93
|
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
|
135
|
-
|
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
|
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
|
-
|
145
|
+
wrapped_callables = proc {|next_middleware| OnErrorCallbacks.new(next_middleware, callables) }
|
146
146
|
|
147
|
-
# Return the combined middleware and wrapped
|
148
|
-
middleware_instances.push(
|
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.
|
4
|
+
version: 6.22.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/bugsnag/integrations/mongo.rb
|
56
56
|
- lib/bugsnag/integrations/que.rb
|
57
57
|
- lib/bugsnag/integrations/rack.rb
|
58
|
+
- lib/bugsnag/integrations/rails/active_job.rb
|
58
59
|
- lib/bugsnag/integrations/rails/active_record_rescue.rb
|
59
60
|
- lib/bugsnag/integrations/rails/controller_methods.rb
|
60
61
|
- lib/bugsnag/integrations/rails/rails_breadcrumbs.rb
|
@@ -64,6 +65,7 @@ files:
|
|
64
65
|
- lib/bugsnag/integrations/shoryuken.rb
|
65
66
|
- lib/bugsnag/integrations/sidekiq.rb
|
66
67
|
- lib/bugsnag/meta_data.rb
|
68
|
+
- lib/bugsnag/middleware/active_job.rb
|
67
69
|
- lib/bugsnag/middleware/breadcrumbs.rb
|
68
70
|
- lib/bugsnag/middleware/callbacks.rb
|
69
71
|
- lib/bugsnag/middleware/classify_error.rb
|
@@ -109,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
111
|
- !ruby/object:Gem::Version
|
110
112
|
version: '0'
|
111
113
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.2.11
|
113
115
|
signing_key:
|
114
116
|
specification_version: 4
|
115
117
|
summary: Ruby notifier for bugsnag.com
|