Class: RailsPerformance::RailsPerformanceController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/rails_performance/rails_performance_controller.rb

Instance Method Summary collapse

Instance Method Details

#crashesObject



40
41
42
43
44
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 40

def crashes
  @datasource   = RailsPerformance::DataSource.new(**prepare_query({status_eq: 500}), type: :requests)
  db            = @datasource.db
  @data         = RailsPerformance::Reports::CrashReport.new(db).data
end

#customObject



104
105
106
107
108
109
110
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 104

def custom
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :custom)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#delayed_jobObject



96
97
98
99
100
101
102
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 96

def delayed_job
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :delayed_job)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#grapeObject



112
113
114
115
116
117
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 112

def grape
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :grape)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#indexObject



9
10
11
12
13
14
15
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 9

def index
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db                         = @datasource.db

  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
end

#rakeObject



119
120
121
122
123
124
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 119

def rake
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :rake)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#recentObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 52

def recent
  @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db          = @datasource.db
  @data       = RailsPerformance::Reports::RecentRequestsReport.new(db).data(params[:from_timei])

  # example
  # :controller=>"HomeController",
  # :action=>"index",
  # :format=>"html",
  # :status=>"200",
  # :method=>"GET",
  # :path=>"/",
  # :request_id=>"9c9bff5f792a5b3f77cb07fa325f8ddf",
  # :datetime=>2023-06-24 21:22:46 +0300,
  # :datetimei=>1687630966,
  # :duration=>207.225830078125,
  # :db_runtime=>2.055999994277954,
  # :view_runtime=>67.8370000096038,
  # :exception=>nil,
  # :backtrace=>nil,
  # :http_referer=>nil,
  # "email"=>nil,
  # "user_agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"}]

  respond_to do |page|
    page.html
    page.js
  end
end

#requestsObject



46
47
48
49
50
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 46

def requests
  @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db          = @datasource.db
  @data       = RailsPerformance::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :count).data
end

#sidekiqObject



88
89
90
91
92
93
94
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 88

def sidekiq
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :sidekiq)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#slowObject



82
83
84
85
86
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 82

def slow
  @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db          = @datasource.db
  @data       = RailsPerformance::Reports::SlowRequestsReport.new(db).data
end

#summaryObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 17

def summary
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db                         = @datasource.db

  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @data                      = RailsPerformance::Reports::BreakdownReport.new(db, title: "Requests").data

  respond_to do |format|
    format.js {}
    format.any { render plain: "Doesn't open in new window. Wait until full page load." }
  end
end

#traceObject



31
32
33
34
35
36
37
38
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 31

def trace
  @record = RailsPerformance::Models::RequestRecord.find_by(request_id: params[:id])
  @data   = RailsPerformance::Reports::TraceReport.new(request_id: params[:id]).data
  respond_to do |format|
    format.js {}
    format.any { render plain: "Doesn't open in new window. Wait until full page load." }
  end
end