Sha256: 41d9d31fae92ffc9a9a36a7950a586c51038875932236eed51283678232d2bb8
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
require "newrelic_route_check/version" require "newrelic_route_check/railtie" if Rails::VERSION::MAJOR.to_i >= 3 require "csv" module NewrelicRouteCheck def self.actions_from_routes controller_actions = application.routes.routes.inject({}) do |controller_actions, route| if route.requirements[:controller] (controller_actions[route.requirements[:controller]] ||= []) << route.requirements[:action] end controller_actions end controller_actions.keys.map{|controller| controller_actions[controller].map{|action| "#{controller.camelize}Controller##{action}"}}.flatten.uniq end def self.actions_from_new_relic(file) new_relic_controller_actions = [] CSV.foreach(file, :col_sep => ",") do |row| if row.first && !['HttpDispatcher','Action'].include?(row.first.chomp) && !row.first.chomp.include?('#(template only)') new_relic_controller_actions << row.first.chomp end end new_relic_controller_actions.uniq end def self.routes_diff_output(new_relic_controller_actions, formatted_routes_actions) puts "found #{new_relic_controller_actions.length} uniq new relic controller action hits" puts "found #{formatted_routes_actions.length} uniq Rails routes controller action pairs" only_new_relic = new_relic_controller_actions - formatted_routes_actions puts "exists in new relic, but not in routes: #{only_new_relic.length}" puts only_new_relic not_hit_in_new_relic = formatted_routes_actions - new_relic_controller_actions puts "never accessed in new relic stats: #{not_hit_in_new_relic.length}" puts not_hit_in_new_relic end private def self.application if Rails::VERSION::MAJOR.to_i >= 3 Rails.application else Rails::Application end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
newrelic_route_check-0.0.3 | lib/newrelic_route_check.rb |
newrelic_route_check-0.0.2 | lib/newrelic_route_check.rb |