Class: SimpleApm::ApmController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SimpleApm::ApmController
- Includes:
- ApplicationHelper
- Defined in:
- app/controllers/simple_apm/apm_controller.rb
Instance Method Summary collapse
- #action_info ⇒ Object
- #actions ⇒ Object
- #change_date ⇒ Object
- #dashboard ⇒ Object
- #index ⇒ Object
- #set_apm_date ⇒ Object
- #show ⇒ Object
Methods included from ApplicationHelper
Methods inherited from ApplicationController
Instance Method Details
#action_info ⇒ Object
45 46 47 |
# File 'app/controllers/simple_apm/apm_controller.rb', line 45 def action_info @action = SimpleApm::Action.find(params[:action_name]) end |
#actions ⇒ Object
41 42 43 |
# File 'app/controllers/simple_apm/apm_controller.rb', line 41 def actions @actions = SimpleApm::Action.all_names.map{|n| SimpleApm::Action.find(n)} end |
#change_date ⇒ Object
49 50 51 52 |
# File 'app/controllers/simple_apm/apm_controller.rb', line 49 def change_date session[:apm_date] = params[:date] redirect_to request.referer end |
#dashboard ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/controllers/simple_apm/apm_controller.rb', line 8 def dashboard d = SimpleApm::RedisKey.query_date == Time.now.strftime('%Y-%m-%d') ? Time.now.strftime('%H:%M') : '23:50' data = SimpleApm::Hit.chart_data(0, d) @x_names = data.keys.sort @time_arr = @x_names.map{|n| data[n][:hits].to_i.zero? ? 0 : (data[n][:time].to_f/data[n][:hits].to_i).round(3) } @hits_arr = @x_names.map{|n| data[n][:hits] rescue 0} end |
#index ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/simple_apm/apm_controller.rb', line 16 def index respond_to do |format| format.json do @slow_requests = SimpleApm::SlowRequest.list(params[:count]||200).map do |r| request = r.request [ link_to(time_label(request.started), show_path(id: request.request_id)), link_to(request.action_name, action_info_path(action_name: request.action_name)), sec_str(request.during), sec_str(request.db_runtime), sec_str(request.view_runtime), request.host, request.remote_addr ] end render json: {data: @slow_requests} end format.html end end |
#set_apm_date ⇒ Object
54 55 56 57 |
# File 'app/controllers/simple_apm/apm_controller.rb', line 54 def set_apm_date # set_query_date redirect_to action: :dashboard end |