airbrake 9.5.1 → 9.5.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
  SHA256:
3
- metadata.gz: 4b5f9ef24127cd1a044a2959d8c90efd26e39db56e85ade6708340fc66009e36
4
- data.tar.gz: 4e79c36be0244afaf4e9716b1d6d7b195cecf3b35bcd0ecfd95afaa426c02c69
3
+ metadata.gz: 5e8ae1c646cf9107329a7413bd0654873c55b47a84a51c7c25d6c7655768c1fd
4
+ data.tar.gz: 516194657a9ceca56fd9843f39d4293a74ccee6db11f6ad084519924eb911b46
5
5
  SHA512:
6
- metadata.gz: 9f8a4e8a07779cee46cb1b7d308db3d97bd9f1008aa4082966dbe0fffc8a043cf78439a7ad8b762887369ce37f1d245b70f9df73a899a1ccfd1b0880854e60bf
7
- data.tar.gz: cf80d00213697bf952a3fa6c20a0cdd936381ced3005dccdefed28d4de912f243390e8916f571a3fbc234766bdfd7b8656cdf143010c14b0d7ef5b06372e51a2
6
+ metadata.gz: 75c112cdf4780dedae3ee51e1d83637f16c2cc1c76fb2cbc077ffa64ebb8dde3aeed4cb589ce3056975fda8f28e36f0dc4e7d212f554a0d413c4d0751bffe02a
7
+ data.tar.gz: 18e7c15a1630ff39730cb1b8c36f21ea333b2b12f202bbb75e0b82e4c3a4676df1c7b2fc4e8c779559c588b34ce8fc2338ef6992c487274e3254a72b47f09464
@@ -14,7 +14,7 @@ module Airbrake
14
14
 
15
15
  notice[:context][:route] =
16
16
  if action_dispatch_request?(request)
17
- Airbrake::Rails::App.recognize_route(request)
17
+ rails_route(request)
18
18
  elsif sinatra_request?(request)
19
19
  sinatra_route(request)
20
20
  end
@@ -22,6 +22,11 @@ module Airbrake
22
22
 
23
23
  private
24
24
 
25
+ def rails_route(request)
26
+ return unless (route = Airbrake::Rails::App.recognize_route(request))
27
+ route.path.spec.to_s
28
+ end
29
+
25
30
  def sinatra_route(request)
26
31
  return unless (route = request.env['sinatra.route'])
27
32
  route.split(' ').drop(1).join(' ')
@@ -3,21 +3,11 @@ require 'airbrake/rails/app'
3
3
 
4
4
  module Airbrake
5
5
  module Rails
6
- # @return [String]
7
- CONTROLLER_KEY = 'controller'.freeze
8
-
9
- # @return [String]
10
- ACTION_KEY = 'action'.freeze
11
-
12
6
  # ActionControllerRouteSubscriber sends route stat information, including
13
7
  # performance data.
14
8
  #
15
9
  # @since v8.0.0
16
10
  class ActionControllerRouteSubscriber
17
- def initialize
18
- @app = Airbrake::Rails::App.new
19
- end
20
-
21
11
  def call(*args)
22
12
  # We don't track routeless events.
23
13
  return unless (routes = Airbrake::Rack::RequestStore[:routes])
@@ -28,12 +18,20 @@ module Airbrake
28
18
  )
29
19
  return unless route
30
20
 
31
- routes[route] = {
21
+ routes[find_route_name(route)] = {
32
22
  method: event.method,
33
23
  response_type: event.response_type,
34
24
  groups: {}
35
25
  }
36
26
  end
27
+
28
+ def find_route_name(route)
29
+ if route.app.respond_to?(:app) && route.app.app.respond_to?(:engine_name)
30
+ "#{route.app.app.engine_name}##{route.path.spec}"
31
+ else
32
+ route.path.spec.to_s
33
+ end
34
+ end
37
35
  end
38
36
  end
39
37
  end
@@ -1,14 +1,12 @@
1
1
  module Airbrake
2
2
  module Rails
3
- # App is a wrapper around Rails.application and Rails::Engine.
3
+ # App is a wrapper around Rails.application.
4
4
  #
5
5
  # @since v9.0.3
6
6
  # @api private
7
7
  class App
8
- Route = Struct.new(:path, :controller, :action)
9
-
10
8
  def self.recognize_route(request)
11
- ::Rails.application.routes.router.recognize(request) do |route, _parameters|
9
+ ::Rails.application.routes.router.recognize(request) do |route, _params|
12
10
  # Rails can recognize multiple routes for the given request. For
13
11
  # example, if we visit /users/2/edit, then Rails sees these routes:
14
12
  # * "/users/:id/edit(.:format)"
@@ -16,41 +14,9 @@ module Airbrake
16
14
  #
17
15
  # We return the first route as, what it seems, the most optimal
18
16
  # approach.
19
- return route.path.spec.to_s
17
+ return route
20
18
  end
21
19
  end
22
-
23
- def routes
24
- @routes ||= app_routes.merge(engine_routes).flat_map do |(engine_name, routes)|
25
- routes.map { |rails_route| build_route(engine_name, rails_route) }
26
- end
27
- end
28
-
29
- private
30
-
31
- def app_routes
32
- # Engine name is nil because this is default (non-engine) routes.
33
- { nil => ::Rails.application.routes.routes.routes }
34
- end
35
-
36
- def engine_routes
37
- ::Rails::Engine.subclasses.flat_map.with_object({}) do |engine, hash|
38
- next if (eng_routes = engine.routes.routes.routes).none?
39
-
40
- hash[engine.engine_name] = eng_routes
41
- end
42
- end
43
-
44
- def build_route(engine_name, rails_route)
45
- engine_prefix = engine_name
46
- engine_prefix += '#' if engine_prefix
47
-
48
- Route.new(
49
- "#{engine_prefix}#{rails_route.path.spec}",
50
- rails_route.defaults[:controller],
51
- rails_route.defaults[:action]
52
- )
53
- end
54
20
  end
55
21
  end
56
22
  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.5.1'.freeze
4
+ AIRBRAKE_VERSION = '9.5.2'.freeze
5
5
  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: 9.5.1
4
+ version: 9.5.2
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-11-25 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake-ruby