newrelic_route_check 0.0.1 → 0.0.2
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.
- data/README.md +5 -2
- data/lib/newrelic_route_check.rb +18 -6
- data/lib/newrelic_route_check/railtie.rb +7 -0
- data/lib/newrelic_route_check/version.rb +1 -1
- metadata +5 -4
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# NewrelicRouteCheck
|
2
2
|
|
3
|
-
|
3
|
+
Compares New Relic controller_summary.csv to the routes defined in a Rails app
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,10 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
This gem requires you use New Relic to download your `controller_summary.csv` from the transaction history tab. Preferably with the 7 day history to have the best coverage. Download the file to `./tmp/controller_summary.csv` then you can run: `bundle exec rake newrelic:compare_with_routes`
|
22
|
+
|
23
|
+
Which should give output of routes that are defined in your app but not receiving any traffic.
|
24
|
+
|
22
25
|
|
23
26
|
## Contributing
|
24
27
|
|
data/lib/newrelic_route_check.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
require "newrelic_route_check/version"
|
2
|
+
require "newrelic_route_check/railtie" if Rails::VERSION::MAJOR.to_i >= 3
|
3
|
+
require "csv"
|
2
4
|
|
3
5
|
module NewrelicRouteCheck
|
4
|
-
|
6
|
+
|
5
7
|
def self.actions_from_routes
|
6
|
-
controller_actions =
|
8
|
+
controller_actions = application.routes.routes.inject({}) do |controller_actions, route|
|
7
9
|
if route.requirements[:controller]
|
8
10
|
(controller_actions[route.requirements[:controller]] ||= []) << route.requirements[:action]
|
9
11
|
end
|
10
12
|
controller_actions
|
11
13
|
end
|
12
|
-
controller_actions.keys.map{|controller| controller_actions[controller].map{|action| "#{controller.camelize}Controller##{action}"}}.flatten.uniq
|
14
|
+
controller_actions.keys.map{|controller| controller_actions[controller].map{|action| "#{controller.camelize}Controller##{action}"}}.flatten.uniq
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.actions_from_new_relic(file)
|
@@ -24,15 +26,25 @@ module NewrelicRouteCheck
|
|
24
26
|
|
25
27
|
def self.routes_diff_output(new_relic_controller_actions, formatted_routes_actions)
|
26
28
|
puts "found #{new_relic_controller_actions.length} uniq new relic controller action hits"
|
27
|
-
puts "found #{formatted_routes_actions.length} uniq controller action pairs"
|
29
|
+
puts "found #{formatted_routes_actions.length} uniq Rails routes controller action pairs"
|
28
30
|
|
29
31
|
only_new_relic = new_relic_controller_actions - formatted_routes_actions
|
30
|
-
puts "exists in new relic, but not in routes: #{only_new_relic.length}"
|
31
|
-
puts only_new_relic
|
32
|
+
puts "exists in new relic, but not in routes: #{only_new_relic.length}"
|
33
|
+
puts only_new_relic
|
32
34
|
|
33
35
|
not_hit_in_new_relic = formatted_routes_actions - new_relic_controller_actions
|
34
36
|
puts "never accessed in new relic stats: #{not_hit_in_new_relic.length}"
|
35
37
|
puts not_hit_in_new_relic
|
36
38
|
end
|
37
39
|
|
40
|
+
private
|
41
|
+
|
42
|
+
def self.application
|
43
|
+
if Rails::VERSION::MAJOR.to_i >= 3
|
44
|
+
Rails.application
|
45
|
+
else
|
46
|
+
Rails::Application
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
38
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_route_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- README.md
|
58
58
|
- Rakefile
|
59
59
|
- lib/newrelic_route_check.rb
|
60
|
+
- lib/newrelic_route_check/railtie.rb
|
60
61
|
- lib/newrelic_route_check/tasks.rb
|
61
62
|
- lib/newrelic_route_check/version.rb
|
62
63
|
- newrelic_route_check.gemspec
|
@@ -75,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
76
|
version: '0'
|
76
77
|
segments:
|
77
78
|
- 0
|
78
|
-
hash:
|
79
|
+
hash: 2457378324206358196
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
none: false
|
81
82
|
requirements:
|
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
version: '0'
|
85
86
|
segments:
|
86
87
|
- 0
|
87
|
-
hash:
|
88
|
+
hash: 2457378324206358196
|
88
89
|
requirements: []
|
89
90
|
rubyforge_project:
|
90
91
|
rubygems_version: 1.8.23
|