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 +4 -4
- data/lib/airbrake/rack/middleware.rb +12 -3
- data/lib/airbrake/rails/action_controller_notify_subscriber.rb +13 -10
- data/lib/airbrake/rails/action_controller_route_subscriber.rb +3 -3
- data/lib/airbrake/rails/active_record_subscriber.rb +12 -9
- data/lib/airbrake/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d59d240ac51340e6085dbe50d6f42e910f5559
|
4
|
+
data.tar.gz: 1d656b05b2343324108a63a5d8af10b9401ce5c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
14
|
+
return if @routes.none?
|
14
15
|
|
15
16
|
event = ActiveSupport::Notifications::Event.new(*args)
|
16
17
|
payload = event.payload
|
17
18
|
|
18
|
-
@
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
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
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
data/lib/airbrake/version.rb
CHANGED