airbrake 8.3.0 → 8.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d66c9a0d425a9603e3834b3031a900af0ca6508
4
- data.tar.gz: 1a7faaaa2dcc1eec9d08768c895e28320b0f6bef
3
+ metadata.gz: 82116cbc8eec2d17547206dc0f644ac974b2df10
4
+ data.tar.gz: a17a8339ced1ac6d9f89aa87cb60a438b5264c58
5
5
  SHA512:
6
- metadata.gz: 860d464f6c7afabacb5771584fdcdcad41d20f15be0ed970324830c5667ca1ee9544e2c02399858bfabe45e8e4719928b85b62ddb20c72cba4bbdb1feab64fc5
7
- data.tar.gz: 8f0b20da65fe963ab10d9b3da7c760a44184c025a33c4160d1e780013938ee606bc83b4c7dece98828e02289806738b987d469ab214d545c1ecc08ed48da58cb
6
+ metadata.gz: 4329f1e59fedbc6769f4f4491b12484b63f50538ff53db3d7f72d693f96f041baaf7ecb576579c9c47e0eff17cb6f4852ca728e08547fa3895205fa9a415003a
7
+ data.tar.gz: bff45ecb23e4fbb8076dd69a10b5be16a3e6659258d4cc92bb41c923d274a5c9ddcd4ed68d09228c64c031aeecfd5cd05e3b8367e83e32296a51bb794e3682f6
@@ -9,6 +9,11 @@ module Airbrake
9
9
  require 'airbrake/rails/action_controller_notify_subscriber'
10
10
  require 'airbrake/rails/action_controller_performance_breakdown_subscriber'
11
11
 
12
+ ActiveSupport::Notifications.subscribe(
13
+ 'process_action.action_controller',
14
+ Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber.new
15
+ )
16
+
12
17
  require 'airbrake/rails/active_record_subscriber' if defined?(ActiveRecord)
13
18
 
14
19
  # Since Rails 3.2 the ActionDispatch::DebugExceptions middleware is
@@ -15,8 +15,8 @@ module Airbrake
15
15
  route: route,
16
16
  response_type: payload[:format],
17
17
  groups: {
18
- db: payload[:db_runtime],
19
- view: payload[:view_runtime]
18
+ db: payload[:db_runtime].to_i,
19
+ view: payload[:view_runtime].to_i
20
20
  },
21
21
  start_time: event.time
22
22
  )
@@ -25,8 +25,3 @@ module Airbrake
25
25
  end
26
26
  end
27
27
  end
28
-
29
- ActiveSupport::Notifications.subscribe(
30
- 'process_action.action_controller',
31
- Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber.new
32
- )
@@ -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.3.0'.freeze
4
+ AIRBRAKE_VERSION = '8.3.1'.freeze
5
5
  end
@@ -0,0 +1,87 @@
1
+ require 'airbrake/rails/action_controller_performance_breakdown_subscriber'
2
+
3
+ RSpec.describe Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber do
4
+ after { Airbrake::Rack::RequestStore[:routes] = nil }
5
+
6
+ context "when routes are not set in the request store" do
7
+ before { Airbrake::Rack::RequestStore[:routes] = nil }
8
+
9
+ it "doesn't send performance breakdown info" do
10
+ expect(Airbrake).not_to receive(:notify_performance_breakdown)
11
+ subject.call([])
12
+ end
13
+ end
14
+
15
+ context "when there are no routes in the request store" do
16
+ before { Airbrake::Rack::RequestStore[:routes] = [] }
17
+
18
+ it "doesn't send performance breakdown info" do
19
+ expect(Airbrake).not_to receive(:notify_performance_breakdown)
20
+ subject.call([])
21
+ end
22
+ end
23
+
24
+ context "when there's a route in the request store" do
25
+ let(:event) do
26
+ OpenStruct.new(
27
+ payload: {
28
+ format: :html,
29
+ view_runtime: 1.0,
30
+ db_runtime: 1.0
31
+ }
32
+ )
33
+ end
34
+
35
+ before do
36
+ Airbrake::Rack::RequestStore[:routes] = [['/test-route', 'GET']]
37
+
38
+ event_dbl = double
39
+ expect(event_dbl).to receive(:new).and_return(event)
40
+ stub_const('ActiveSupport::Notifications::Event', event_dbl)
41
+ end
42
+
43
+ it "sends performance info to Airbrake" do
44
+ expect(Airbrake).to receive(:notify_performance_breakdown).with(
45
+ hash_including(
46
+ route: '/test-route',
47
+ method: 'GET',
48
+ response_type: :html,
49
+ groups: { db: 1.0, view: 1.0 }
50
+ )
51
+ )
52
+ subject.call([])
53
+ end
54
+
55
+ context "and when view_runtime is nil" do
56
+ before { event.payload[:view_runtime] = nil }
57
+
58
+ it "sets the view group runtime to 0" do
59
+ expect(Airbrake).to receive(:notify_performance_breakdown).with(
60
+ hash_including(
61
+ route: '/test-route',
62
+ method: 'GET',
63
+ response_type: :html,
64
+ groups: { db: 1.0, view: 0 }
65
+ )
66
+ )
67
+ subject.call([])
68
+ end
69
+ end
70
+
71
+ context "and when db_runtime is nil" do
72
+ before { event.payload[:db_runtime] = nil }
73
+
74
+ it "sets the view group runtime to 0" do
75
+ expect(Airbrake).to receive(:notify_performance_breakdown).with(
76
+ hash_including(
77
+ route: '/test-route',
78
+ method: 'GET',
79
+ response_type: :html,
80
+ groups: { db: 0, view: 1.0 }
81
+ )
82
+ )
83
+ subject.call([])
84
+ end
85
+ end
86
+ end
87
+ 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.3.0
4
+ version: 8.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
@@ -319,6 +319,7 @@ files:
319
319
  - spec/unit/rack/user_filter_spec.rb
320
320
  - spec/unit/rack/user_spec.rb
321
321
  - spec/unit/rails/action_cable/notify_callback_spec.rb
322
+ - spec/unit/rails/action_controller_performance_breakdown_subscriber_spec.rb
322
323
  - spec/unit/rake/tasks_spec.rb
323
324
  - spec/unit/shoryuken_spec.rb
324
325
  - spec/unit/sidekiq/retryable_jobs_filter_spec.rb
@@ -367,6 +368,7 @@ test_files:
367
368
  - spec/unit/rack/user_filter_spec.rb
368
369
  - spec/unit/rack/user_spec.rb
369
370
  - spec/unit/rack/route_filter_spec.rb
371
+ - spec/unit/rails/action_controller_performance_breakdown_subscriber_spec.rb
370
372
  - spec/unit/rails/action_cable/notify_callback_spec.rb
371
373
  - spec/integration/sinatra/sinatra_spec.rb
372
374
  - spec/integration/rack/rack_spec.rb