airbrake 10.0.6 → 11.0.3

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: a8c1a47736f8dd93e0023e7ac0ce9d8e5e852baaba52bd725203577c3881d058
4
- data.tar.gz: d0f623664683c44ca43cf29b067fe72ed4c7b7920e9390f0346ca1cc3b8ae409
3
+ metadata.gz: bd22c4ba5f388c063021267c805f9f72f9905c8e0f7a2b7e19d0f6a45c9718a9
4
+ data.tar.gz: b919ee2bdae1a073c939b752d9827f3d8ecd6c30f18739019f9becbf6974a605
5
5
  SHA512:
6
- metadata.gz: 22c50e2be09ff46299ec304ef79fb28f69a4017170b5c67f8abf9633a891e8b51d7a197d6d7568b1cfe2ee11a2a2b916f12f88896d0488fb3ae37c999b277a36
7
- data.tar.gz: 59747af59ca1ec23c3cd1ba31ec3e42daa922ce85bb49e1306a4b13d3b75fc8ab41365607dd7558277f301db6aaee8865862749003ce6e65aa1598fca10914bd
6
+ metadata.gz: 2362a03c41aebeddaf2e6bcd2272760ea0fb94b88a0dcabb644ab5c9b3a72ed72281f05f314f04491e27d99fae9c5353bbfaa4fc1d43f09d3e2316f6edfb02ba
7
+ data.tar.gz: f260895a27e6f8e2368c2be1431344291d5dcdf731f0d4b71d4ab2f14de1265cb93759c888ad03592b02dabaa7944e9c4dfbfed4fb87b443e3aaddeba0321760
@@ -13,7 +13,7 @@ namespace :airbrake do
13
13
  REVISION=#{fetch(:current_revision)} \
14
14
  REPOSITORY=#{fetch(:repo_url)} \
15
15
  VERSION=#{fetch(:app_version)}
16
- CMD
16
+ CMD
17
17
 
18
18
  info 'Notified Airbrake of the deploy'
19
19
  end
data/lib/airbrake/rack.rb CHANGED
@@ -18,6 +18,8 @@ module Airbrake
18
18
  # @since v9.2.0
19
19
  # @api public
20
20
  def self.capture_timing(label)
21
+ return yield unless Airbrake::Config.instance.performance_stats
22
+
21
23
  routes = Airbrake::Rack::RequestStore[:routes]
22
24
  if !routes || routes.none?
23
25
  result = yield
@@ -8,10 +8,10 @@ module Airbrake
8
8
  class HttpHeadersFilter
9
9
  # @return [Array<String>] the prefixes of the majority of HTTP headers in
10
10
  # Rack (some prefixes match the header names for simplicity)
11
- HTTP_HEADER_PREFIXES = [
12
- 'HTTP_'.freeze,
13
- 'CONTENT_TYPE'.freeze,
14
- 'CONTENT_LENGTH'.freeze,
11
+ HTTP_HEADER_PREFIXES = %w[
12
+ HTTP_
13
+ CONTENT_TYPE
14
+ CONTENT_LENGTH
15
15
  ].freeze
16
16
 
17
17
  # @return [Integer]
@@ -98,11 +98,11 @@ module Airbrake
98
98
  def self.method_visibility(klass, method_name)
99
99
  klass.module_exec do
100
100
  if protected_method_defined?(method_name)
101
- "protected".freeze
101
+ "protected"
102
102
  elsif private_method_defined?(method_name)
103
- "private".freeze
103
+ "private"
104
104
  else
105
- "public".freeze
105
+ "public"
106
106
  end
107
107
  end
108
108
  end
@@ -111,11 +111,11 @@ module Airbrake
111
111
  # A method instead of a constant so it isn't accessible in the target.
112
112
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7")
113
113
  def self.method_signature
114
- "*args, **kw_args, &block".freeze
114
+ "*args, **kw_args, &block"
115
115
  end
116
116
  else
117
117
  def self.method_signature
118
- "*args, &block".freeze
118
+ "*args, &block"
119
119
  end
120
120
  end
121
121
 
@@ -28,11 +28,13 @@ module Airbrake
28
28
 
29
29
  def rails_route(request)
30
30
  return unless (route = Airbrake::Rails::App.recognize_route(request))
31
+
31
32
  route.path
32
33
  end
33
34
 
34
35
  def sinatra_route(request)
35
36
  return unless (route = request.env['sinatra.route'])
37
+
36
38
  route.split(' ').drop(1).join(' ')
37
39
  end
38
40
 
@@ -28,6 +28,7 @@ module Airbrake
28
28
  controller = rack_env['action_controller.instance']
29
29
  return unless controller.respond_to?(:current_user, true)
30
30
  return unless [-1, 0].include?(controller.method(:current_user).arity)
31
+
31
32
  begin
32
33
  controller.__send__(:current_user)
33
34
  rescue Exception => _e # rubocop:disable Lint/RescueException
@@ -59,6 +60,7 @@ module Airbrake
59
60
  # try methods with no arguments or with variable number of arguments,
60
61
  # where none of them are required
61
62
  return unless @user.method(key).arity.between?(-1, 0)
63
+
62
64
  String(@user.__send__(key))
63
65
  end
64
66
 
@@ -6,16 +6,14 @@ module Airbrake
6
6
  # Rails namespace holds all Rails-related functionality.
7
7
  module Rails
8
8
  def self.logger
9
+ # Rails.logger is not set in some Rake tasks such as
10
+ # 'airbrake:deploy'. In this case we use a sensible fallback.
11
+ level = (::Rails.logger ? ::Rails.logger.level : Logger::ERROR)
12
+
9
13
  if ENV['RAILS_LOG_TO_STDOUT'].present?
10
- Logger.new(STDOUT, level: ::Rails.logger.level)
14
+ Logger.new(STDOUT, level: level)
11
15
  else
12
- Logger.new(
13
- ::Rails.root.join('log', 'airbrake.log'),
14
-
15
- # Rails.logger is not set in some Rake tasks such as
16
- # 'airbrake:deploy'. In this case we use a sensible fallback.
17
- level: (::Rails.logger ? ::Rails.logger.level : Logger::ERROR),
18
- )
16
+ Logger.new(::Rails.root.join('log', 'airbrake.log'), level: level)
19
17
  end
20
18
  end
21
19
  end
@@ -10,26 +10,28 @@ require 'airbrake/rails/action_cable/notify_callback'
10
10
  end
11
11
  end
12
12
 
13
- module ActionCable
14
- module Channel
15
- # @since v8.3.0
16
- # @api private
17
- # @see https://github.com/rails/rails/blob/master/actioncable/lib/action_cable/channel/base.rb
18
- class Base
19
- alias perform_action_without_airbrake perform_action
13
+ module Airbrake
14
+ module ActionCable
15
+ module Channel
16
+ # @since v8.3.0
17
+ # @api private
18
+ # @see https://github.com/rails/rails/blob/master/actioncable/lib/action_cable/channel/base.rb
19
+ module Base
20
+ def perform_action(*args, &block)
21
+ super(*args, &block)
22
+ rescue Exception => ex # rubocop:disable Lint/RescueException
23
+ Airbrake.notify(ex) do |notice|
24
+ notice.stash[:action_cable_connection] = connection
25
+ notice[:context][:component] = self.class
26
+ notice[:context][:action] = args.first['action']
27
+ notice[:params].merge!(args.first)
28
+ end
20
29
 
21
- def perform_action(*args, &block)
22
- perform_action_without_airbrake(*args, &block)
23
- rescue Exception => ex # rubocop:disable Lint/RescueException
24
- Airbrake.notify(ex) do |notice|
25
- notice.stash[:action_cable_connection] = connection
26
- notice[:context][:component] = self.class
27
- notice[:context][:action] = args.first['action']
28
- notice[:params].merge!(args.first)
30
+ raise ex
29
31
  end
30
-
31
- raise ex
32
32
  end
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ ActionCable::Channel::Base.prepend(Airbrake::ActionCable::Channel::Base)
@@ -14,6 +14,7 @@ module Airbrake
14
14
  # @see Airbrake#notify, #notify_airbrake_sync
15
15
  def notify_airbrake(exception, params = {}, &block)
16
16
  return unless (notice = build_notice(exception, params))
17
+
17
18
  Airbrake.notify(notice, params, &block)
18
19
  end
19
20
 
@@ -22,6 +23,7 @@ module Airbrake
22
23
  # @see Airbrake#notify_sync, #notify_airbrake
23
24
  def notify_airbrake_sync(exception, params = {}, &block)
24
25
  return unless (notice = build_notice(exception, params))
26
+
25
27
  Airbrake.notify_sync(notice, params, &block)
26
28
  end
27
29
 
@@ -29,6 +31,7 @@ module Airbrake
29
31
  # @return [Airbrake::Notice] the notice with information from the Rack env
30
32
  def build_notice(exception, params = {})
31
33
  return unless (notice = Airbrake.build_notice(exception, params))
34
+
32
35
  notice.stash[:rack_request] = request
33
36
  notice
34
37
  end
@@ -10,6 +10,8 @@ module Airbrake
10
10
  # @since v8.0.0
11
11
  class ActionControllerNotifySubscriber
12
12
  def call(*args)
13
+ return unless Airbrake::Config.instance.performance_stats
14
+
13
15
  routes = Airbrake::Rack::RequestStore[:routes]
14
16
  return if !routes || routes.none?
15
17
 
@@ -7,6 +7,8 @@ module Airbrake
7
7
  # @since v8.3.0
8
8
  class ActionControllerPerformanceBreakdownSubscriber
9
9
  def call(*args)
10
+ return unless Airbrake::Config.instance.performance_stats
11
+
10
12
  routes = Airbrake::Rack::RequestStore[:routes]
11
13
  return if !routes || routes.none?
12
14
 
@@ -11,6 +11,8 @@ module Airbrake
11
11
  # @since v8.0.0
12
12
  class ActionControllerRouteSubscriber
13
13
  def call(*args)
14
+ return unless Airbrake::Config.instance.performance_stats
15
+
14
16
  # We don't track routeless events.
15
17
  return unless (routes = Airbrake::Rack::RequestStore[:routes])
16
18
 
@@ -10,6 +10,8 @@ module Airbrake
10
10
  # @since v8.1.0
11
11
  class ActiveRecordSubscriber
12
12
  def call(*args)
13
+ return unless Airbrake::Config.instance.query_stats
14
+
13
15
  routes = Airbrake::Rack::RequestStore[:routes]
14
16
  return if !routes || routes.none?
15
17
 
@@ -5,7 +5,7 @@ module Airbrake
5
5
  # BacktraceCleaner is a wrapper around Rails.backtrace_cleaner.
6
6
  class BacktraceCleaner
7
7
  # @return [Regexp]
8
- AIRBRAKE_FRAME_PATTERN = %r{/airbrake/lib/airbrake/}
8
+ AIRBRAKE_FRAME_PATTERN = %r{/airbrake/lib/airbrake/}.freeze
9
9
 
10
10
  def self.clean(backtrace)
11
11
  ::Rails.backtrace_cleaner.clean(backtrace).first(1)
@@ -1,37 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Curl
4
- # Monkey-patch to measure request timing.
5
- class Easy
6
- alias http_without_airbrake http
7
-
8
- def http(verb)
9
- Airbrake::Rack.capture_timing(:http) do
10
- http_without_airbrake(verb)
3
+ module Airbrake
4
+ module Rails
5
+ # Allows measuring request timing.
6
+ module CurlEasy
7
+ def http(verb)
8
+ Airbrake::Rack.capture_timing(:http) do
9
+ super(verb)
10
+ end
11
11
  end
12
- end
13
-
14
- alias perform_without_airbrake perform
15
12
 
16
- def perform(&block)
17
- Airbrake::Rack.capture_timing(:http) do
18
- perform_without_airbrake(&block)
13
+ def perform(&block)
14
+ Airbrake::Rack.capture_timing(:http) do
15
+ super(&block)
16
+ end
19
17
  end
20
18
  end
21
- end
22
- end
23
-
24
- module Curl
25
- # Monkey-patch to measure request timing.
26
- class Multi
27
- class << self
28
- alias http_without_airbrake http
29
19
 
20
+ # Allows measuring request timing.
21
+ module CurlMulti
30
22
  def http(urls_with_config, multi_options = {}, &block)
31
23
  Airbrake::Rack.capture_timing(:http) do
32
- http_without_airbrake(urls_with_config, multi_options, &block)
24
+ super(urls_with_config, multi_options, &block)
33
25
  end
34
26
  end
35
27
  end
36
28
  end
37
29
  end
30
+
31
+ Curl::Easy.prepend(Airbrake::Rails::CurlEasy)
32
+ Curl::Multi.singleton_class.prepend(Airbrake::Rails::CurlMulti)
@@ -8,7 +8,7 @@ module Airbrake
8
8
  # @api private
9
9
  class Event
10
10
  # @see https://github.com/rails/rails/issues/8987
11
- HTML_RESPONSE_WILDCARD = "*/*".freeze
11
+ HTML_RESPONSE_WILDCARD = "*/*"
12
12
 
13
13
  include Airbrake::Loggable
14
14
 
@@ -8,6 +8,8 @@ module Airbrake
8
8
  # @since v9.2.0
9
9
  class Excon
10
10
  def call(*args)
11
+ return unless Airbrake::Config.instance.performance_stats
12
+
11
13
  routes = Airbrake::Rack::RequestStore[:routes]
12
14
  return if !routes || routes.none?
13
15
 
@@ -1,14 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module HTTP
4
- # Monkey-patch to measure request timing.
5
- class Client
6
- alias perform_without_airbrake perform
7
-
8
- def perform(request, options)
9
- Airbrake::Rack.capture_timing(:http) do
10
- perform_without_airbrake(request, options)
3
+ module Airbrake
4
+ module Rails
5
+ # Monkey-patch to measure request timing.
6
+ # @api private
7
+ # @since v11.0.2
8
+ module HTTP
9
+ def perform(request, options)
10
+ Airbrake::Rack.capture_timing(:http) do
11
+ super(request, options)
12
+ end
11
13
  end
12
14
  end
13
15
  end
14
16
  end
17
+
18
+ HTTP::Client.prepend(Airbrake::Rails::HTTP)
@@ -1,12 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Monkey-patch to measure request timing.
4
- class HTTPClient
5
- alias do_get_without_airbrake do_get_block
6
-
7
- def do_get_block(request, proxy, connection, &block)
8
- Airbrake::Rack.capture_timing(:http) do
9
- do_get_without_airbrake(request, proxy, connection, &block)
3
+ module Airbrake
4
+ module Rails
5
+ # Allows measuring request timing.
6
+ module HTTPClient
7
+ def do_get_block(request, proxy, connection, &block)
8
+ Airbrake::Rack.capture_timing(:http) do
9
+ super(request, proxy, connection, &block)
10
+ end
11
+ end
10
12
  end
11
13
  end
12
14
  end
15
+
16
+ HTTPClient.prepend(Airbrake::Rails::HTTPClient)
@@ -6,9 +6,9 @@ module Airbrake
6
6
  # 3.2+ apps). It makes Airbrake Ruby work with Rails and report errors
7
7
  # occurring in the application automatically.
8
8
  #
9
- # rubocop:disable Metrics/ClassLength, Metrics/BlockLength
9
+ # rubocop:disable Metrics/BlockLength
10
10
  class Railtie < ::Rails::Railtie
11
- initializer('airbrake.middleware', after: :load_config_initializers) do |app|
11
+ initializer('airbrake.middleware') do |app|
12
12
  # Since Rails 3.2 the ActionDispatch::DebugExceptions middleware is
13
13
  # responsible for logging exceptions and showing a debugging page in
14
14
  # case the request is local. We want to insert our middleware after
@@ -53,43 +53,37 @@ module Airbrake
53
53
  require 'airbrake/rails/action_controller'
54
54
  include Airbrake::Rails::ActionController
55
55
 
56
- if Airbrake::Config.instance.performance_stats
57
- # Cache route information for the duration of the request.
58
- require 'airbrake/rails/action_controller_route_subscriber'
59
- ActiveSupport::Notifications.subscribe(
60
- 'start_processing.action_controller',
61
- Airbrake::Rails::ActionControllerRouteSubscriber.new,
62
- )
63
-
64
- # Send route stats.
65
- require 'airbrake/rails/action_controller_notify_subscriber'
66
- ActiveSupport::Notifications.subscribe(
67
- 'process_action.action_controller',
68
- Airbrake::Rails::ActionControllerNotifySubscriber.new,
69
- )
70
-
71
- # Send performance breakdown: where a request spends its time.
72
- require 'airbrake/rails/action_controller_performance_breakdown_subscriber'
73
- ActiveSupport::Notifications.subscribe(
74
- 'process_action.action_controller',
75
- Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber.new,
76
- )
56
+ # Cache route information for the duration of the request.
57
+ require 'airbrake/rails/action_controller_route_subscriber'
58
+ ActiveSupport::Notifications.subscribe(
59
+ 'start_processing.action_controller',
60
+ Airbrake::Rails::ActionControllerRouteSubscriber.new,
61
+ )
77
62
 
78
- require 'airbrake/rails/net_http' if defined?(Net) && defined?(Net::HTTP)
63
+ # Send route stats.
64
+ require 'airbrake/rails/action_controller_notify_subscriber'
65
+ ActiveSupport::Notifications.subscribe(
66
+ 'process_action.action_controller',
67
+ Airbrake::Rails::ActionControllerNotifySubscriber.new,
68
+ )
79
69
 
80
- if defined?(Curl) && defined?(Curl::CURB_VERSION)
81
- require 'airbrake/rails/curb'
82
- end
70
+ # Send performance breakdown: where a request spends its time.
71
+ require 'airbrake/rails/action_controller_performance_breakdown_subscriber'
72
+ ActiveSupport::Notifications.subscribe(
73
+ 'process_action.action_controller',
74
+ Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber.new,
75
+ )
83
76
 
84
- require 'airbrake/rails/http' if defined?(HTTP) && defined?(HTTP::Client)
85
- require 'airbrake/rails/http_client' if defined?(HTTPClient)
86
- require 'airbrake/rails/typhoeus' if defined?(Typhoeus)
77
+ require 'airbrake/rails/net_http' if defined?(Net) && defined?(Net::HTTP)
78
+ require 'airbrake/rails/curb' if defined?(Curl) && defined?(Curl::CURB_VERSION)
79
+ require 'airbrake/rails/http' if defined?(HTTP) && defined?(HTTP::Client)
80
+ require 'airbrake/rails/http_client' if defined?(HTTPClient)
81
+ require 'airbrake/rails/typhoeus' if defined?(Typhoeus)
87
82
 
88
- if defined?(Excon)
89
- require 'airbrake/rails/excon_subscriber'
90
- ActiveSupport::Notifications.subscribe(/excon/, Airbrake::Rails::Excon.new)
91
- ::Excon.defaults[:instrumentor] = ActiveSupport::Notifications
92
- end
83
+ if defined?(Excon)
84
+ require 'airbrake/rails/excon_subscriber'
85
+ ActiveSupport::Notifications.subscribe(/excon/, Airbrake::Rails::Excon.new)
86
+ ::Excon.defaults[:instrumentor] = ActiveSupport::Notifications
93
87
  end
94
88
  end
95
89
  end
@@ -104,7 +98,7 @@ module Airbrake
104
98
  include Airbrake::Rails::ActiveRecord
105
99
  end
106
100
 
107
- if defined?(ActiveRecord) && Airbrake::Config.instance.query_stats
101
+ if defined?(ActiveRecord)
108
102
  # Send SQL queries.
109
103
  require 'airbrake/rails/active_record_subscriber'
110
104
  ActiveSupport::Notifications.subscribe(
@@ -152,6 +146,6 @@ module Airbrake
152
146
  end
153
147
  end
154
148
  end
155
- # rubocop:enable Metrics/ClassLength, Metrics/BlockLength
149
+ # rubocop:enable Metrics/BlockLength
156
150
  end
157
151
  end
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Typhoeus
4
- # Monkey-patch to measure request timing.
5
- class Request
6
- alias run_without_airbrake run
7
-
8
- def run
9
- Airbrake::Rack.capture_timing(:http) do
10
- run_without_airbrake
3
+ module Airbrake
4
+ module Rails
5
+ # Allow measuring request timing.
6
+ module TyphoeusRequest
7
+ def run
8
+ Airbrake::Rack.capture_timing(:http) do
9
+ super
10
+ end
11
11
  end
12
12
  end
13
13
  end
14
14
  end
15
+
16
+ Typhoeus::Request.prepend(Airbrake::Rails::TyphoeusRequest)
data/lib/airbrake/rake.rb CHANGED
@@ -5,61 +5,62 @@
5
5
  # See: https://goo.gl/ksn6PE
6
6
  Rake::TaskManager.record_task_metadata = true
7
7
 
8
- module Rake
9
- # Redefine +Rake::Task#execute+, so it can report errors to Airbrake.
10
- class Task
11
- # Store the original method to use it later.
12
- alias execute_without_airbrake execute
13
-
14
- # A wrapper around the original +#execute+, that catches all errors and
15
- # notifies Airbrake.
16
- #
17
- # rubocop:disable Lint/RescueException
18
- def execute(args = nil)
19
- execute_without_airbrake(args)
20
- rescue Exception => ex
21
- notify_airbrake(ex, args)
22
- raise ex
23
- end
24
- # rubocop:enable Lint/RescueException
8
+ module Airbrake
9
+ module Rake
10
+ # Redefine +Rake::Task#execute+, so it can report errors to Airbrake.
11
+ module Task
12
+ # A wrapper around the original +#execute+, that catches all errors and
13
+ # notifies Airbrake.
14
+ #
15
+ # rubocop:disable Lint/RescueException
16
+ def execute(args = nil)
17
+ super(args)
18
+ rescue Exception => ex
19
+ notify_airbrake(ex, args)
20
+ raise ex
21
+ end
22
+ # rubocop:enable Lint/RescueException
25
23
 
26
- private
24
+ private
27
25
 
28
- def notify_airbrake(exception, args)
29
- notice = Airbrake.build_notice(exception)
30
- notice[:context][:component] = 'rake'
31
- notice[:context][:action] = name
32
- notice[:params].merge!(
33
- rake_task: task_info,
34
- execute_args: args,
35
- argv: ARGV.join(' '),
36
- )
26
+ def notify_airbrake(exception, args)
27
+ notice = Airbrake.build_notice(exception)
28
+ notice[:context][:component] = 'rake'
29
+ notice[:context][:action] = name
30
+ notice[:params].merge!(
31
+ rake_task: task_info,
32
+ execute_args: args,
33
+ argv: ARGV.join(' '),
34
+ )
37
35
 
38
- Airbrake.notify_sync(notice)
39
- end
36
+ Airbrake.notify_sync(notice)
37
+ end
40
38
 
41
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
42
- def task_info
43
- info = {}
39
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
40
+ def task_info
41
+ info = {}
44
42
 
45
- info[:name] = name
46
- info[:timestamp] = timestamp.to_s
47
- info[:investigation] = investigation
43
+ info[:name] = name
44
+ info[:timestamp] = timestamp.to_s
45
+ info[:investigation] = investigation
48
46
 
49
- info[:full_comment] = full_comment if full_comment
50
- info[:arg_names] = arg_names if arg_names.any?
51
- info[:arg_description] = arg_description if arg_description
52
- info[:locations] = locations if locations.any?
53
- info[:sources] = sources if sources.any?
47
+ info[:full_comment] = full_comment if full_comment
48
+ info[:arg_names] = arg_names if arg_names.any?
49
+ info[:arg_description] = arg_description if arg_description
50
+ info[:locations] = locations if locations.any?
51
+ info[:sources] = sources if sources.any?
54
52
 
55
- if prerequisite_tasks.any?
56
- info[:prerequisite_tasks] = prerequisite_tasks.map do |p|
57
- p.__send__(:task_info)
53
+ if prerequisite_tasks.any?
54
+ info[:prerequisite_tasks] = prerequisite_tasks.map do |p|
55
+ p.__send__(:task_info)
56
+ end
58
57
  end
59
- end
60
58
 
61
- info
59
+ info
60
+ end
61
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize
62
62
  end
63
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize
64
63
  end
65
64
  end
65
+
66
+ Rake::Task.prepend(Airbrake::Rake::Task)
@@ -71,7 +71,7 @@ namespace :airbrake do
71
71
  app = ENV['HEROKU_APP']
72
72
 
73
73
  config = Bundler.with_clean_env do
74
- `heroku config --shell#{ " --app #{app}" if app }`
74
+ `heroku config --shell#{" --app #{app}" if app}`
75
75
  end
76
76
 
77
77
  heroku_env = config.each_line.with_object({}) do |line, h|
@@ -30,32 +30,33 @@ module Resque
30
30
  end
31
31
  end
32
32
 
33
- module Resque
34
- # Measures elapsed time of a job and notifies Airbrake of the execution
35
- # status.
36
- #
37
- # @since v9.6.0
38
- class Job
39
- # Store the original method to use it later.
40
- alias perform_without_airbrake perform
41
-
42
- def perform
43
- timing = Airbrake::Benchmark.measure do
44
- perform_without_airbrake
33
+ module Airbrake
34
+ module Resque
35
+ # Measures elapsed time of a job and notifies Airbrake of the execution
36
+ # status.
37
+ #
38
+ # @since v9.6.0
39
+ module Job
40
+ def perform
41
+ timing = Airbrake::Benchmark.measure do
42
+ super
43
+ end
44
+ rescue StandardError => exception
45
+ Airbrake.notify_queue_sync(
46
+ queue: payload['class'],
47
+ error_count: 1,
48
+ timing: 0.01,
49
+ )
50
+ raise exception
51
+ else
52
+ Airbrake.notify_queue_sync(
53
+ queue: payload['class'],
54
+ error_count: 0,
55
+ timing: timing,
56
+ )
45
57
  end
46
- rescue StandardError => exception
47
- Airbrake.notify_queue_sync(
48
- queue: payload['class'],
49
- error_count: 1,
50
- timing: 0.01,
51
- )
52
- raise exception
53
- else
54
- Airbrake.notify_queue_sync(
55
- queue: payload['class'],
56
- error_count: 0,
57
- timing: timing,
58
- )
59
58
  end
60
59
  end
61
60
  end
61
+
62
+ Resque::Job.prepend(Airbrake::Resque::Job)
@@ -29,7 +29,7 @@ module Airbrake
29
29
  private
30
30
 
31
31
  def notify_airbrake(exception, context)
32
- Airbrake.notify(exception, context) do |notice|
32
+ Airbrake.notify(exception, job: context) do |notice|
33
33
  notice[:context][:component] = 'sidekiq'
34
34
  notice[:context][:action] = action(context)
35
35
  end
@@ -41,6 +41,7 @@ module Airbrake
41
41
  klass = context['class'] || context[:job] && context[:job]['class']
42
42
  return klass unless context[:job] && context[:job]['args'].first.is_a?(Hash)
43
43
  return klass unless (job_class = context[:job]['args'].first['job_class'])
44
+
44
45
  job_class
45
46
  end
46
47
  end
@@ -26,6 +26,7 @@ module Airbrake
26
26
 
27
27
  def filter_context(context)
28
28
  return context unless context[:delivery_info]
29
+
29
30
  h = context.dup
30
31
  h[:delivery_info] = context[:delivery_info].reject do |k, _v|
31
32
  IGNORED_KEYS.include?(k)
@@ -38,34 +39,36 @@ end
38
39
 
39
40
  Sneakers.error_reporters << Airbrake::Sneakers::ErrorReporter.new
40
41
 
41
- module Sneakers
42
- # @todo Migrate to Sneakers v2.12.0 middleware API when it's released
43
- # @see https://github.com/jondot/sneakers/pull/364
44
- module Worker
45
- # Sneakers v2.7.0+ renamed `do_work` to `process_work`.
46
- if method_defined?(:process_work)
47
- alias process_work_without_airbrake process_work
48
- else
49
- alias process_work_without_airbrake do_work
50
- end
51
-
52
- def process_work(delivery_info, metadata, msg, handler)
53
- timing = Airbrake::Benchmark.measure do
54
- process_work_without_airbrake(delivery_info, metadata, msg, handler)
42
+ module Airbrake
43
+ module Sneakers
44
+ # @todo Migrate to Sneakers v2.12.0 middleware API when it's released
45
+ # @see https://github.com/jondot/sneakers/pull/364
46
+ module Worker
47
+ # Sneakers v2.7.0+ renamed `do_work` to `process_work`.
48
+ define_method(
49
+ ::Sneakers::Worker.method_defined?(:process_work) ? :process_work : :do_work,
50
+ ) do |delivery_info, metadata, msg, handler|
51
+ begin
52
+ timing = Airbrake::Benchmark.measure do
53
+ super(delivery_info, metadata, msg, handler)
54
+ end
55
+ rescue Exception => exception # rubocop:disable Lint/RescueException
56
+ Airbrake.notify_queue(
57
+ queue: self.class.to_s,
58
+ error_count: 1,
59
+ timing: 0.01,
60
+ )
61
+ raise exception
62
+ else
63
+ Airbrake.notify_queue(
64
+ queue: self.class.to_s,
65
+ error_count: 0,
66
+ timing: timing,
67
+ )
68
+ end
55
69
  end
56
- rescue Exception => exception # rubocop:disable Lint/RescueException
57
- Airbrake.notify_queue(
58
- queue: self.class.to_s,
59
- error_count: 1,
60
- timing: 0.01,
61
- )
62
- raise exception
63
- else
64
- Airbrake.notify_queue(
65
- queue: self.class.to_s,
66
- error_count: 0,
67
- timing: timing,
68
- )
69
70
  end
70
71
  end
71
72
  end
73
+
74
+ Sneakers::Worker.prepend(Airbrake::Sneakers::Worker)
@@ -3,5 +3,5 @@
3
3
  # We use Semantic Versioning v2.0.0
4
4
  # More information: http://semver.org/
5
5
  module Airbrake
6
- AIRBRAKE_VERSION = '10.0.6'.freeze
6
+ AIRBRAKE_VERSION = '11.0.3'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.6
4
+ version: 11.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-14 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.13'
19
+ version: '5.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.13'
26
+ version: '5.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '12'
61
+ version: '13'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '12'
68
+ version: '13'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -84,72 +84,72 @@ dependencies:
84
84
  name: appraisal
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 2.2.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.2.0
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rack
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1'
103
+ version: '2'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1'
110
+ version: '2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2'
117
+ version: '3'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2'
124
+ version: '3'
125
125
  - !ruby/object:Gem::Dependency
126
- name: sneakers
126
+ name: amq-protocol
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '2'
131
+ version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '2'
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: amq-protocol
140
+ name: sneakers
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 2.2.0
145
+ version: '2'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '='
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 2.2.0
152
+ version: '2'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rack-test
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,202 +170,146 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 3.3.3
173
+ version: 4.1.4
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 3.3.3
180
+ version: 4.1.4
181
181
  - !ruby/object:Gem::Dependency
182
- name: public_suffix
182
+ name: sidekiq
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '2.0'
188
- - - "<"
189
- - !ruby/object:Gem::Version
190
- version: '3.0'
187
+ version: '5'
191
188
  type: :development
192
189
  prerelease: false
193
190
  version_requirements: !ruby/object:Gem::Requirement
194
191
  requirements:
195
192
  - - "~>"
196
193
  - !ruby/object:Gem::Version
197
- version: '2.0'
198
- - - "<"
199
- - !ruby/object:Gem::Version
200
- version: '3.0'
201
- - !ruby/object:Gem::Dependency
202
- name: nokogiri
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - '='
206
- - !ruby/object:Gem::Version
207
- version: 1.9.1
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - '='
213
- - !ruby/object:Gem::Version
214
- version: 1.9.1
215
- - !ruby/object:Gem::Dependency
216
- name: parallel
217
- requirement: !ruby/object:Gem::Requirement
218
- requirements:
219
- - - '='
220
- - !ruby/object:Gem::Version
221
- version: 1.13.0
222
- type: :development
223
- prerelease: false
224
- version_requirements: !ruby/object:Gem::Requirement
225
- requirements:
226
- - - '='
227
- - !ruby/object:Gem::Version
228
- version: 1.13.0
229
- - !ruby/object:Gem::Dependency
230
- name: minitest
231
- requirement: !ruby/object:Gem::Requirement
232
- requirements:
233
- - - '='
234
- - !ruby/object:Gem::Version
235
- version: 5.11.3
236
- type: :development
237
- prerelease: false
238
- version_requirements: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - '='
241
- - !ruby/object:Gem::Version
242
- version: 5.11.3
243
- - !ruby/object:Gem::Dependency
244
- name: rack-cache
245
- requirement: !ruby/object:Gem::Requirement
246
- requirements:
247
- - - '='
248
- - !ruby/object:Gem::Version
249
- version: 1.9.0
250
- type: :development
251
- prerelease: false
252
- version_requirements: !ruby/object:Gem::Requirement
253
- requirements:
254
- - - '='
255
- - !ruby/object:Gem::Version
256
- version: 1.9.0
194
+ version: '5'
257
195
  - !ruby/object:Gem::Dependency
258
- name: redis-namespace
196
+ name: curb
259
197
  requirement: !ruby/object:Gem::Requirement
260
198
  requirements:
261
- - - '='
199
+ - - "~>"
262
200
  - !ruby/object:Gem::Version
263
- version: 1.6.0
201
+ version: '0.9'
264
202
  type: :development
265
203
  prerelease: false
266
204
  version_requirements: !ruby/object:Gem::Requirement
267
205
  requirements:
268
- - - '='
206
+ - - "~>"
269
207
  - !ruby/object:Gem::Version
270
- version: 1.6.0
208
+ version: '0.9'
271
209
  - !ruby/object:Gem::Dependency
272
- name: ffi
210
+ name: excon
273
211
  requirement: !ruby/object:Gem::Requirement
274
212
  requirements:
275
- - - '='
213
+ - - "~>"
276
214
  - !ruby/object:Gem::Version
277
- version: 1.12.2
215
+ version: '0.64'
278
216
  type: :development
279
217
  prerelease: false
280
218
  version_requirements: !ruby/object:Gem::Requirement
281
219
  requirements:
282
- - - '='
220
+ - - "~>"
283
221
  - !ruby/object:Gem::Version
284
- version: 1.12.2
222
+ version: '0.64'
285
223
  - !ruby/object:Gem::Dependency
286
- name: sidekiq
224
+ name: http
287
225
  requirement: !ruby/object:Gem::Requirement
288
226
  requirements:
289
227
  - - "~>"
290
228
  - !ruby/object:Gem::Version
291
- version: '5'
229
+ version: '2.2'
292
230
  type: :development
293
231
  prerelease: false
294
232
  version_requirements: !ruby/object:Gem::Requirement
295
233
  requirements:
296
234
  - - "~>"
297
235
  - !ruby/object:Gem::Version
298
- version: '5'
236
+ version: '2.2'
299
237
  - !ruby/object:Gem::Dependency
300
- name: curb
238
+ name: httpclient
301
239
  requirement: !ruby/object:Gem::Requirement
302
240
  requirements:
303
241
  - - "~>"
304
242
  - !ruby/object:Gem::Version
305
- version: '0.9'
243
+ version: '2.8'
306
244
  type: :development
307
245
  prerelease: false
308
246
  version_requirements: !ruby/object:Gem::Requirement
309
247
  requirements:
310
248
  - - "~>"
311
249
  - !ruby/object:Gem::Version
312
- version: '0.9'
250
+ version: '2.8'
313
251
  - !ruby/object:Gem::Dependency
314
- name: excon
252
+ name: typhoeus
315
253
  requirement: !ruby/object:Gem::Requirement
316
254
  requirements:
317
255
  - - "~>"
318
256
  - !ruby/object:Gem::Version
319
- version: '0.64'
257
+ version: '1.3'
320
258
  type: :development
321
259
  prerelease: false
322
260
  version_requirements: !ruby/object:Gem::Requirement
323
261
  requirements:
324
262
  - - "~>"
325
263
  - !ruby/object:Gem::Version
326
- version: '0.64'
264
+ version: '1.3'
327
265
  - !ruby/object:Gem::Dependency
328
- name: http
266
+ name: ethon
329
267
  requirement: !ruby/object:Gem::Requirement
330
268
  requirements:
331
- - - "~>"
269
+ - - '='
332
270
  - !ruby/object:Gem::Version
333
- version: '2.2'
271
+ version: 0.12.0
334
272
  type: :development
335
273
  prerelease: false
336
274
  version_requirements: !ruby/object:Gem::Requirement
337
275
  requirements:
338
- - - "~>"
276
+ - - '='
339
277
  - !ruby/object:Gem::Version
340
- version: '2.2'
278
+ version: 0.12.0
341
279
  - !ruby/object:Gem::Dependency
342
- name: httpclient
280
+ name: public_suffix
343
281
  requirement: !ruby/object:Gem::Requirement
344
282
  requirements:
345
283
  - - "~>"
346
284
  - !ruby/object:Gem::Version
347
- version: '2.8'
285
+ version: '4.0'
286
+ - - "<"
287
+ - !ruby/object:Gem::Version
288
+ version: '5.0'
348
289
  type: :development
349
290
  prerelease: false
350
291
  version_requirements: !ruby/object:Gem::Requirement
351
292
  requirements:
352
293
  - - "~>"
353
294
  - !ruby/object:Gem::Version
354
- version: '2.8'
295
+ version: '4.0'
296
+ - - "<"
297
+ - !ruby/object:Gem::Version
298
+ version: '5.0'
355
299
  - !ruby/object:Gem::Dependency
356
- name: typhoeus
300
+ name: redis-namespace
357
301
  requirement: !ruby/object:Gem::Requirement
358
302
  requirements:
359
- - - "~>"
303
+ - - '='
360
304
  - !ruby/object:Gem::Version
361
- version: '1.3'
305
+ version: 1.6.0
362
306
  type: :development
363
307
  prerelease: false
364
308
  version_requirements: !ruby/object:Gem::Requirement
365
309
  requirements:
366
- - - "~>"
310
+ - - '='
367
311
  - !ruby/object:Gem::Version
368
- version: '1.3'
312
+ version: 1.6.0
369
313
  description: |
370
314
  Airbrake is an online tool that provides robust exception tracking in any of
371
315
  your Ruby applications. In doing so, it allows you to easily review errors, tie
@@ -442,7 +386,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
442
386
  requirements:
443
387
  - - ">="
444
388
  - !ruby/object:Gem::Version
445
- version: '2.1'
389
+ version: '2.3'
446
390
  required_rubygems_version: !ruby/object:Gem::Requirement
447
391
  requirements:
448
392
  - - ">="