airbrake 9.4.3 → 9.4.4

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
  SHA1:
3
- metadata.gz: fe9037ca230b5a680582dff789221db846fd346e
4
- data.tar.gz: 6471b5f85ac64b3031aeca6c9f7d4a37a437496e
3
+ metadata.gz: 645e4f963a8955c17a652cf468917e2ae514f849
4
+ data.tar.gz: 4f383442884699b67bd81943fd1c64cb527eb2d1
5
5
  SHA512:
6
- metadata.gz: 503a6f588f31ac85581e4b9906614941a8680f3b45ac7b7e1da5d115c3064e116debb15c55e5e68f9d4daf46f419804f90cb0a931b1d9eb8b5bfef644a8f2cd7
7
- data.tar.gz: ae3d0ebc69c627c5df4a69f83fb96ec9be1dfcd88e883adeacf63ea516f56f7623d78862666f8a1e92df278265b3c8454e9f33f0a0548dc49a4b20124471a653
6
+ metadata.gz: dab6ccce21fc171ef09f1d3e103ca6a02e943f997d17731da3d752ffcc789f46647789b189b827a26daace21683edc9dc6d3ada9dfebff3e869f5881d945ec5f
7
+ data.tar.gz: 3f2582844fd96b45c1e378a30b5950e32b05393630c2b716e15ffe49c244321e42f1db0646c3d3bf2a315efa09c07d8d16a3a72064c1a8f6c57be36200e09dbd
@@ -26,7 +26,11 @@ module Airbrake
26
26
  controller = rack_env['action_controller.instance']
27
27
  return unless controller.respond_to?(:current_user, true)
28
28
  return unless [-1, 0].include?(controller.method(:current_user).arity)
29
- controller.__send__(:current_user)
29
+ begin
30
+ controller.__send__(:current_user)
31
+ rescue Exception => _e # rubocop:disable Lint/RescueException
32
+ nil
33
+ end
30
34
  end
31
35
  private_class_method :try_current_user
32
36
 
@@ -1,140 +1,19 @@
1
+ require 'airbrake/rails/railtie'
2
+
1
3
  module Airbrake
4
+ # Rails namespace holds all Rails-related functionality.
2
5
  module Rails
3
- # This railtie works for any Rails application that supports railties (Rails
4
- # 3.2+ apps). It makes Airbrake Ruby work with Rails and report errors
5
- # occurring in the application automatically.
6
- class Railtie < ::Rails::Railtie
7
- initializer('airbrake.middleware') do |app|
8
- # Since Rails 3.2 the ActionDispatch::DebugExceptions middleware is
9
- # responsible for logging exceptions and showing a debugging page in
10
- # case the request is local. We want to insert our middleware after
11
- # DebugExceptions, so we don't notify Airbrake about local requests.
12
-
13
- if ::Rails.version.to_i >= 5
14
- # Avoid the warning about deprecated strings.
15
- # Insert after DebugExceptions, since ConnectionManagement doesn't
16
- # exist in Rails 5 anymore.
17
- app.config.middleware.insert_after(
18
- ActionDispatch::DebugExceptions,
19
- Airbrake::Rack::Middleware
20
- )
21
- elsif defined?(::ActiveRecord::ConnectionAdapters::ConnectionManagement)
22
- # Insert after ConnectionManagement to avoid DB connection leakage:
23
- # https://github.com/airbrake/airbrake/pull/568
24
- app.config.middleware.insert_after(
25
- ::ActiveRecord::ConnectionAdapters::ConnectionManagement,
26
- 'Airbrake::Rack::Middleware'
27
- )
28
- else
29
- # Insert after DebugExceptions for apps without ActiveRecord.
30
- app.config.middleware.insert_after(
31
- ActionDispatch::DebugExceptions,
32
- 'Airbrake::Rack::Middleware'
33
- )
34
- end
35
- end
36
-
37
- rake_tasks do
38
- # Report exceptions occurring in Rake tasks.
39
- require 'airbrake/rake'
40
-
41
- # Defines tasks such as `airbrake:test` & `airbrake:deploy`.
42
- require 'airbrake/rake/tasks'
43
- end
44
-
45
- # rubocop:disable Metrics/BlockLength
46
- initializer('airbrake.action_controller') do
47
- ActiveSupport.on_load(:action_controller) do
48
- # Patches ActionController with methods that allow us to retrieve
49
- # interesting request data. Appends that information to notices.
50
- require 'airbrake/rails/action_controller'
51
- include Airbrake::Rails::ActionController
52
-
53
- if Airbrake::Config.instance.performance_stats
54
- # Cache route information for the duration of the request.
55
- require 'airbrake/rails/action_controller_route_subscriber'
56
- ActiveSupport::Notifications.subscribe(
57
- 'start_processing.action_controller',
58
- Airbrake::Rails::ActionControllerRouteSubscriber.new
59
- )
60
-
61
- # Send route stats.
62
- require 'airbrake/rails/action_controller_notify_subscriber'
63
- ActiveSupport::Notifications.subscribe(
64
- 'process_action.action_controller',
65
- Airbrake::Rails::ActionControllerNotifySubscriber.new
66
- )
67
-
68
- # Send performance breakdown: where a request spends its time.
69
- require 'airbrake/rails/action_controller_performance_breakdown_subscriber'
70
- ActiveSupport::Notifications.subscribe(
71
- 'process_action.action_controller',
72
- Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber.new
73
- )
74
-
75
- require 'airbrake/rails/net_http' if defined?(Net) && defined?(Net::HTTP)
76
-
77
- if defined?(Curl) && defined?(Curl::CURB_VERSION)
78
- require 'airbrake/rails/curb'
79
- end
80
-
81
- require 'airbrake/rails/http' if defined?(HTTP) && defined?(HTTP::Client)
82
- require 'airbrake/rails/http_client' if defined?(HTTPClient)
83
- require 'airbrake/rails/typhoeus' if defined?(Typhoeus)
84
-
85
- if defined?(Excon)
86
- require 'airbrake/rails/excon_subscriber'
87
- ActiveSupport::Notifications.subscribe(/excon/, Airbrake::Rails::Excon.new)
88
- ::Excon.defaults[:instrumentor] = ActiveSupport::Notifications
89
- end
90
- end
91
- end
92
- end
93
- # rubocop:enable Metrics/BlockLength
94
-
95
- initializer('airbrake.active_record') do
96
- ActiveSupport.on_load(:active_record) do
97
- # Reports exceptions occurring in some bugged ActiveRecord callbacks.
98
- # Applicable only to the versions of Rails lower than 4.2.
99
- require 'airbrake/rails/active_record'
100
- include Airbrake::Rails::ActiveRecord
101
-
102
- if defined?(ActiveRecord) && Airbrake::Config.instance.query_stats
103
- # Send SQL queries.
104
- require 'airbrake/rails/active_record_subscriber'
105
- ActiveSupport::Notifications.subscribe(
106
- 'sql.active_record', Airbrake::Rails::ActiveRecordSubscriber.new
107
- )
108
-
109
- # Filter out parameters from SQL body.
110
- Airbrake.add_performance_filter(
111
- Airbrake::Filters::SqlFilter.new(
112
- ::ActiveRecord::Base.connection_config[:adapter]
113
- )
114
- )
115
- end
116
- end
117
- end
118
-
119
- initializer('airbrake.active_job') do
120
- ActiveSupport.on_load(:active_job) do
121
- # Reports exceptions occurring in ActiveJob jobs.
122
- require 'airbrake/rails/active_job'
123
- include Airbrake::Rails::ActiveJob
124
- end
125
- end
126
-
127
- initializer('airbrake.action_cable') do
128
- ActiveSupport.on_load(:action_cable) do
129
- # Reports exceptions occurring in ActionCable connections.
130
- require 'airbrake/rails/action_cable'
131
- end
132
- end
133
-
134
- runner do
135
- at_exit do
136
- Airbrake.notify_sync($ERROR_INFO) if $ERROR_INFO
137
- end
6
+ def self.logger
7
+ if ENV['RAILS_LOG_TO_STDOUT'].present?
8
+ Logger.new(STDOUT, level: ::Rails.logger.level)
9
+ else
10
+ Logger.new(
11
+ ::Rails.root.join('log', 'airbrake.log'),
12
+
13
+ # Rails.logger is not set in some Rake tasks such as
14
+ # 'airbrake:deploy'. In this case we use a sensible fallback.
15
+ level: (::Rails.logger ? ::Rails.logger.level : Logger::ERROR)
16
+ )
138
17
  end
139
18
  end
140
19
  end
@@ -10,17 +10,17 @@ module Airbrake
10
10
  # A helper method for sending notices to Airbrake *asynchronously*.
11
11
  # Attaches information from the Rack env.
12
12
  # @see Airbrake#notify, #notify_airbrake_sync
13
- def notify_airbrake(exception, params = {})
13
+ def notify_airbrake(exception, params = {}, &block)
14
14
  return unless (notice = build_notice(exception, params))
15
- Airbrake.notify(notice, params)
15
+ Airbrake.notify(notice, params, &block)
16
16
  end
17
17
 
18
18
  # A helper method for sending notices to Airbrake *synchronously*.
19
19
  # Attaches information from the Rack env.
20
20
  # @see Airbrake#notify_sync, #notify_airbrake
21
- def notify_airbrake_sync(exception, params = {})
21
+ def notify_airbrake_sync(exception, params = {}, &block)
22
22
  return unless (notice = build_notice(exception, params))
23
- Airbrake.notify_sync(notice, params)
23
+ Airbrake.notify_sync(notice, params, &block)
24
24
  end
25
25
 
26
26
  # @param [Exception] exception
@@ -0,0 +1,141 @@
1
+ module Airbrake
2
+ module Rails
3
+ # This railtie works for any Rails application that supports railties (Rails
4
+ # 3.2+ apps). It makes Airbrake Ruby work with Rails and report errors
5
+ # occurring in the application automatically.
6
+ class Railtie < ::Rails::Railtie
7
+ initializer('airbrake.middleware') do |app|
8
+ # Since Rails 3.2 the ActionDispatch::DebugExceptions middleware is
9
+ # responsible for logging exceptions and showing a debugging page in
10
+ # case the request is local. We want to insert our middleware after
11
+ # DebugExceptions, so we don't notify Airbrake about local requests.
12
+
13
+ if ::Rails.version.to_i >= 5
14
+ # Avoid the warning about deprecated strings.
15
+ # Insert after DebugExceptions, since ConnectionManagement doesn't
16
+ # exist in Rails 5 anymore.
17
+ app.config.middleware.insert_after(
18
+ ActionDispatch::DebugExceptions,
19
+ Airbrake::Rack::Middleware
20
+ )
21
+ elsif defined?(::ActiveRecord::ConnectionAdapters::ConnectionManagement)
22
+ # Insert after ConnectionManagement to avoid DB connection leakage:
23
+ # https://github.com/airbrake/airbrake/pull/568
24
+ app.config.middleware.insert_after(
25
+ ::ActiveRecord::ConnectionAdapters::ConnectionManagement,
26
+ 'Airbrake::Rack::Middleware'
27
+ )
28
+ else
29
+ # Insert after DebugExceptions for apps without ActiveRecord.
30
+ app.config.middleware.insert_after(
31
+ ActionDispatch::DebugExceptions,
32
+ 'Airbrake::Rack::Middleware'
33
+ )
34
+ end
35
+ end
36
+
37
+ rake_tasks do
38
+ # Report exceptions occurring in Rake tasks.
39
+ require 'airbrake/rake'
40
+
41
+ # Defines tasks such as `airbrake:test` & `airbrake:deploy`.
42
+ require 'airbrake/rake/tasks'
43
+ end
44
+
45
+ # rubocop:disable Metrics/BlockLength
46
+ initializer('airbrake.action_controller') do
47
+ ActiveSupport.on_load(:action_controller) do
48
+ # Patches ActionController with methods that allow us to retrieve
49
+ # interesting request data. Appends that information to notices.
50
+ require 'airbrake/rails/action_controller'
51
+ include Airbrake::Rails::ActionController
52
+
53
+ if Airbrake::Config.instance.performance_stats
54
+ # Cache route information for the duration of the request.
55
+ require 'airbrake/rails/action_controller_route_subscriber'
56
+ ActiveSupport::Notifications.subscribe(
57
+ 'start_processing.action_controller',
58
+ Airbrake::Rails::ActionControllerRouteSubscriber.new
59
+ )
60
+
61
+ # Send route stats.
62
+ require 'airbrake/rails/action_controller_notify_subscriber'
63
+ ActiveSupport::Notifications.subscribe(
64
+ 'process_action.action_controller',
65
+ Airbrake::Rails::ActionControllerNotifySubscriber.new
66
+ )
67
+
68
+ # Send performance breakdown: where a request spends its time.
69
+ require 'airbrake/rails/action_controller_performance_breakdown_subscriber'
70
+ ActiveSupport::Notifications.subscribe(
71
+ 'process_action.action_controller',
72
+ Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber.new
73
+ )
74
+
75
+ require 'airbrake/rails/net_http' if defined?(Net) && defined?(Net::HTTP)
76
+
77
+ if defined?(Curl) && defined?(Curl::CURB_VERSION)
78
+ require 'airbrake/rails/curb'
79
+ end
80
+
81
+ require 'airbrake/rails/http' if defined?(HTTP) && defined?(HTTP::Client)
82
+ require 'airbrake/rails/http_client' if defined?(HTTPClient)
83
+ require 'airbrake/rails/typhoeus' if defined?(Typhoeus)
84
+
85
+ if defined?(Excon)
86
+ require 'airbrake/rails/excon_subscriber'
87
+ ActiveSupport::Notifications.subscribe(/excon/, Airbrake::Rails::Excon.new)
88
+ ::Excon.defaults[:instrumentor] = ActiveSupport::Notifications
89
+ end
90
+ end
91
+ end
92
+ end
93
+ # rubocop:enable Metrics/BlockLength
94
+
95
+ initializer('airbrake.active_record') do
96
+ ActiveSupport.on_load(:active_record) do
97
+ # Reports exceptions occurring in some bugged ActiveRecord callbacks.
98
+ # Applicable only to the versions of Rails lower than 4.2.
99
+ require 'airbrake/rails/active_record'
100
+ include Airbrake::Rails::ActiveRecord
101
+
102
+ if defined?(ActiveRecord) && Airbrake::Config.instance.query_stats
103
+ # Send SQL queries.
104
+ require 'airbrake/rails/active_record_subscriber'
105
+ ActiveSupport::Notifications.subscribe(
106
+ 'sql.active_record', Airbrake::Rails::ActiveRecordSubscriber.new
107
+ )
108
+
109
+ # Filter out parameters from SQL body.
110
+ Airbrake.add_performance_filter(
111
+ Airbrake::Filters::SqlFilter.new(
112
+ ::ActiveRecord::Base.connection_config[:adapter]
113
+ )
114
+ )
115
+ end
116
+ end
117
+ end
118
+
119
+ initializer('airbrake.active_job') do
120
+ ActiveSupport.on_load(:active_job) do
121
+ # Reports exceptions occurring in ActiveJob jobs.
122
+ require 'airbrake/rails/active_job'
123
+ include Airbrake::Rails::ActiveJob
124
+ end
125
+ end
126
+
127
+ initializer('airbrake.action_cable') do
128
+ ActiveSupport.on_load(:action_cable) do
129
+ # Reports exceptions occurring in ActionCable connections.
130
+ require 'airbrake/rails/action_cable'
131
+ end
132
+ end
133
+
134
+ runner do
135
+ at_exit do
136
+ Airbrake.notify_sync($ERROR_INFO) if $ERROR_INFO
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
@@ -1,5 +1,5 @@
1
1
  # We use Semantic Versioning v2.0.0
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
- AIRBRAKE_VERSION = '9.4.3'.freeze
4
+ AIRBRAKE_VERSION = '9.4.4'.freeze
5
5
  end
@@ -33,15 +33,7 @@ Airbrake.configure do |c|
33
33
  # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense to
34
34
  # use the Rails' logger.
35
35
  # https://github.com/airbrake/airbrake-ruby#logger
36
- c.logger =
37
- if ENV['RAILS_LOG_TO_STDOUT'].present?
38
- Logger.new(STDOUT, level: Rails.logger.level)
39
- else
40
- Logger.new(
41
- Rails.root.join('log', 'airbrake.log'),
42
- level: Rails.logger.level
43
- )
44
- end
36
+ c.logger = Airbrake::Rails.logger
45
37
 
46
38
  # Configures the environment the application is running in. Helps the Airbrake
47
39
  # dashboard to distinguish between exceptions occurring in different
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: 9.4.3
4
+ version: 9.4.4
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: 2019-08-08 00:00:00.000000000 Z
11
+ date: 2019-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake-ruby
@@ -362,6 +362,7 @@ files:
362
362
  - lib/airbrake/rails/http.rb
363
363
  - lib/airbrake/rails/http_client.rb
364
364
  - lib/airbrake/rails/net_http.rb
365
+ - lib/airbrake/rails/railtie.rb
365
366
  - lib/airbrake/rails/typhoeus.rb
366
367
  - lib/airbrake/rake.rb
367
368
  - lib/airbrake/rake/tasks.rb