airbrake 8.1.1 → 8.1.2

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: 8819ab2225ac8b9224d2ee701aaf3815a1c18af8
4
- data.tar.gz: 44e4c87574f7add4d6a71e5029ddd82e6f26847e
3
+ metadata.gz: 23d59d240ac51340e6085dbe50d6f42e910f5559
4
+ data.tar.gz: 1d656b05b2343324108a63a5d8af10b9401ce5c2
5
5
  SHA512:
6
- metadata.gz: b1641b28731f4c05bee5863b3cd59563184a2a17c67c1805654127bf05dba293022f30bb2e1a44bd2da8188d9847fa5632b0eb6c41c3603041a3f23f932ce757
7
- data.tar.gz: a0f83696463bc113eabf5f47cecb9ebc6aa3b23e191f8f83a8f8f1f93ba7d18c08bcaeeb75824bde742c3ca2642c25b53c367c8b9e0a509b088c0e7dcaecea2a
6
+ metadata.gz: 5662473402d0e4c6838927750cb45e6efc9b38f1dc74c605c1d54e3b300a36950f69b04cb79cb0cb627cfb16127d5268a3d3e4358df3f4b950a5abd733ca668f
7
+ data.tar.gz: 8dbdcbdd1c49fafd94f0c51fcd89fff87772ad39ed3bf82afdf249b42dec447fbafd41e979e99b271cbfde45d2f4a57c66fcc542187ddf6f4cdc10b1b96e2d1a
@@ -34,6 +34,10 @@ module Airbrake
34
34
  @notice_notifier = Airbrake.notifiers[:notice][notifier_name]
35
35
  @performance_notifier = Airbrake.notifiers[:performance][notifier_name]
36
36
 
37
+ # This object is shared among hooks. ActionControllerRouteSubscriber
38
+ # writes it and other hooks read it.
39
+ @routes = {}
40
+
37
41
  # Prevent adding same filters to the same notifier.
38
42
  return if @@known_notifiers.include?(notifier_name)
39
43
  @@known_notifiers << notifier_name
@@ -57,6 +61,9 @@ module Airbrake
57
61
  rescue Exception => ex
58
62
  notify_airbrake(ex, env)
59
63
  raise ex
64
+ ensure
65
+ # Clear routes for the next request.
66
+ @routes.clear
60
67
  end
61
68
  # rubocop:enable Lint/RescueException
62
69
 
@@ -101,13 +108,13 @@ module Airbrake
101
108
  def install_action_controller_hooks
102
109
  ActiveSupport::Notifications.subscribe(
103
110
  'start_processing.action_controller',
104
- Airbrake::Rails::ActionControllerRouteSubscriber.new
111
+ Airbrake::Rails::ActionControllerRouteSubscriber.new(@routes)
105
112
  )
106
113
 
107
114
  ActiveSupport::Notifications.subscribe(
108
115
  'process_action.action_controller',
109
116
  Airbrake::Rails::ActionControllerNotifySubscriber.new(
110
- @performance_notifier
117
+ @performance_notifier, @routes
111
118
  )
112
119
  )
113
120
  end
@@ -120,7 +127,9 @@ module Airbrake
120
127
  )
121
128
  ActiveSupport::Notifications.subscribe(
122
129
  'sql.active_record',
123
- Airbrake::Rails::ActiveRecordSubscriber.new(@performance_notifier)
130
+ Airbrake::Rails::ActiveRecordSubscriber.new(
131
+ @performance_notifier, @routes
132
+ )
124
133
  )
125
134
  end
126
135
  end
@@ -5,25 +5,28 @@ module Airbrake
5
5
  #
6
6
  # @since v8.0.0
7
7
  class ActionControllerNotifySubscriber
8
- def initialize(notifier)
8
+ def initialize(notifier, routes)
9
9
  @notifier = notifier
10
+ @routes = routes
10
11
  end
11
12
 
12
13
  def call(*args)
13
- return unless (route = Thread.current[:airbrake_rails_route])
14
+ return if @routes.none?
14
15
 
15
16
  event = ActiveSupport::Notifications::Event.new(*args)
16
17
  payload = event.payload
17
18
 
18
- @notifier.notify(
19
- Airbrake::Request.new(
20
- method: payload[:method],
21
- route: route,
22
- status_code: find_status_code(payload),
23
- start_time: event.time,
24
- end_time: Time.new
19
+ @routes.each do |route, method|
20
+ @notifier.notify(
21
+ Airbrake::Request.new(
22
+ method: method,
23
+ route: route,
24
+ status_code: find_status_code(payload),
25
+ start_time: event.time,
26
+ end_time: Time.new
27
+ )
25
28
  )
26
- )
29
+ end
27
30
  end
28
31
 
29
32
  private
@@ -5,7 +5,8 @@ module Airbrake
5
5
  #
6
6
  # @since v8.0.0
7
7
  class ActionControllerRouteSubscriber
8
- def initialize
8
+ def initialize(routes)
9
+ @routes = routes
9
10
  @all_routes = nil
10
11
  end
11
12
 
@@ -17,8 +18,7 @@ module Airbrake
17
18
  event = ActiveSupport::Notifications::Event.new(*args)
18
19
  payload = event.payload
19
20
 
20
- Thread.current[:airbrake_rails_route] = find_route(payload[:params])
21
- Thread.current[:airbrake_rails_method] = payload[:method]
21
+ @routes[find_route(payload[:params])] = payload[:method]
22
22
  end
23
23
 
24
24
  private
@@ -4,21 +4,24 @@ module Airbrake
4
4
  #
5
5
  # @since v8.1.0
6
6
  class ActiveRecordSubscriber
7
- def initialize(notifier)
7
+ def initialize(notifier, routes)
8
8
  @notifier = notifier
9
+ @routes = routes
9
10
  end
10
11
 
11
12
  def call(*args)
12
13
  event = ActiveSupport::Notifications::Event.new(*args)
13
- @notifier.notify(
14
- Airbrake::Query.new(
15
- route: Thread.current[:airbrake_rails_route],
16
- method: Thread.current[:airbrake_rails_method],
17
- query: event.payload[:sql],
18
- start_time: event.time,
19
- end_time: event.end
14
+ @routes.each do |route, method|
15
+ @notifier.notify(
16
+ Airbrake::Query.new(
17
+ route: route,
18
+ method: method,
19
+ query: event.payload[:sql],
20
+ start_time: event.time,
21
+ end_time: event.end
22
+ )
20
23
  )
21
- )
24
+ end
22
25
  end
23
26
  end
24
27
  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 = '8.1.1'.freeze
4
+ AIRBRAKE_VERSION = '8.1.2'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.1
4
+ version: 8.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.