rails_performance 0.9.8 → 1.0.0.beta4
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.
- checksums.yaml +4 -4
- data/README.md +36 -5
- data/app/controllers/rails_performance/rails_performance_controller.rb +48 -36
- data/app/helpers/rails_performance/application_helper.rb +25 -7
- data/app/views/rails_performance/javascripts/app.js +2 -2
- data/app/views/rails_performance/layouts/rails_performance.html.erb +1 -1
- data/app/views/rails_performance/rails_performance/_summary.html.erb +1 -1
- data/app/views/rails_performance/rails_performance/crashes.html.erb +6 -0
- data/app/views/rails_performance/rails_performance/custom.html.erb +83 -0
- data/app/views/rails_performance/rails_performance/delayed_job.html.erb +74 -0
- data/app/views/rails_performance/rails_performance/grape.html.erb +64 -0
- data/app/views/rails_performance/rails_performance/rake.html.erb +55 -0
- data/app/views/rails_performance/rails_performance/recent.html.erb +3 -1
- data/app/views/rails_performance/rails_performance/{jobs.html.erb → sidekiq.html.erb} +5 -4
- data/app/views/rails_performance/rails_performance/summary.js.erb +1 -1
- data/app/views/rails_performance/rails_performance/trace.js.erb +1 -1
- data/app/views/rails_performance/shared/_header.html.erb +9 -1
- data/app/views/rails_performance/stylesheets/style.css +9 -0
- data/config/routes.rb +5 -1
- data/lib/rails_performance.rb +30 -9
- data/lib/rails_performance/data_source.rb +55 -16
- data/lib/rails_performance/engine.rb +38 -18
- data/lib/rails_performance/extensions/{capture_everything.rb → trace.rb} +2 -2
- data/lib/rails_performance/gems/custom_ext.rb +33 -0
- data/lib/rails_performance/gems/delayed_job_ext.rb +54 -0
- data/lib/rails_performance/gems/grape_ext.rb +35 -0
- data/lib/rails_performance/gems/rake_ext.rb +40 -0
- data/lib/rails_performance/gems/{sidekiq.rb → sidekiq_ext.rb} +13 -12
- data/lib/rails_performance/instrument/metrics_collector.rb +10 -3
- data/lib/rails_performance/models/base_record.rb +12 -0
- data/lib/rails_performance/models/custom_record.rb +48 -0
- data/lib/rails_performance/models/delayed_job_record.rb +62 -0
- data/lib/rails_performance/models/grape_record.rb +61 -0
- data/lib/rails_performance/models/rake_record.rb +49 -0
- data/lib/rails_performance/models/request_record.rb +111 -0
- data/lib/rails_performance/models/sidekiq_record.rb +66 -0
- data/lib/rails_performance/models/trace_record.rb +19 -0
- data/lib/rails_performance/rails/middleware.rb +42 -16
- data/lib/rails_performance/rails/query_builder.rb +1 -1
- data/lib/rails_performance/reports/breakdown_report.rb +4 -16
- data/lib/rails_performance/reports/crash_report.rb +4 -15
- data/lib/rails_performance/reports/recent_requests_report.rb +7 -44
- data/lib/rails_performance/reports/trace_report.rb +2 -2
- data/lib/rails_performance/{models → thread}/current_request.rb +9 -4
- data/lib/rails_performance/utils.rb +15 -28
- data/lib/rails_performance/version.rb +2 -1
- metadata +93 -10
- data/lib/rails_performance/models/job_record.rb +0 -48
- data/lib/rails_performance/models/record.rb +0 -68
@@ -0,0 +1,74 @@
|
|
1
|
+
<title>Delayed::Job</title>
|
2
|
+
|
3
|
+
<% unless @datasource.default? %>
|
4
|
+
<%#= link_to raw("← Back"), rails_performance_path, class: "back_link" %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<div class="card">
|
8
|
+
<div class="card-content">
|
9
|
+
<h2 class="subtitle">Delayed::Job Workers Throughput Report</h2>
|
10
|
+
<div id="throughput_report_chart" class="chart"></div>
|
11
|
+
<p class="content is-small">All workers in the application</p>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<br/>
|
16
|
+
|
17
|
+
<div class="card">
|
18
|
+
<div class="card-content">
|
19
|
+
<h2 class="subtitle">Average Execution Time</h2>
|
20
|
+
<div id="response_time_report_chart" class="chart"></div>
|
21
|
+
<p class="content is-small">All workers in the application</p>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<br/>
|
26
|
+
|
27
|
+
<div class="card">
|
28
|
+
<div class="card-content">
|
29
|
+
<h2 class="subtitle">Recent Jobs (last <%= RailsPerformance::Reports::RecentRequestsReport::TIME_WINDOW / 60 %> minutes)<h2>
|
30
|
+
|
31
|
+
<table class="table is-fullwidth is-hoverable is-narrow">
|
32
|
+
<thead>
|
33
|
+
<tr>
|
34
|
+
<th data-sort="string">Datetime</th>
|
35
|
+
<th data-sort="string">Job ID</th>
|
36
|
+
<th data-sort="string">Type</th>
|
37
|
+
<th data-sort="string">Class</th>
|
38
|
+
<th data-sort="string">Method</th>
|
39
|
+
<th data-sort="string">Status</th>
|
40
|
+
<th data-sort="float">Duration</th>
|
41
|
+
</tr>
|
42
|
+
</thead>
|
43
|
+
<tbody>
|
44
|
+
<% if @recent_report_data.empty? %>
|
45
|
+
<tr>
|
46
|
+
<td colspan="10">Nothing to show here. Try to make a few requests in the main app.</td>
|
47
|
+
</tr>
|
48
|
+
<% end %>
|
49
|
+
<% @recent_report_data.each do |e| %>
|
50
|
+
<tr>
|
51
|
+
<td><%= format_datetime e[:datetime] %></td>
|
52
|
+
<td><%= e[:jid] %></td>
|
53
|
+
<td><%= e[:source_type] %></td>
|
54
|
+
<td><%= e[:class_name] %></td>
|
55
|
+
<td><%= e[:method_name] %></td>
|
56
|
+
<td><%= status_tag e[:status] %></td>
|
57
|
+
<td class="nowrap"><%= ms e[:duration], 1 %></td>
|
58
|
+
</tr>
|
59
|
+
<% end %>
|
60
|
+
</tbody>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
</div>
|
64
|
+
|
65
|
+
|
66
|
+
<% content_for :on_load do %>
|
67
|
+
<script>
|
68
|
+
var data1 = <%= raw @throughput_report_data.to_json %>;
|
69
|
+
showTIRChart('throughput_report_chart', data1, ' jobs / minute', 'Jobs');
|
70
|
+
|
71
|
+
var data2 = <%= raw @response_time_report_data.to_json %>;
|
72
|
+
showRTChart('response_time_report_chart', data2);
|
73
|
+
</script>
|
74
|
+
<% end %>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<title>Grape</title>
|
2
|
+
|
3
|
+
<% unless @datasource.default? %>
|
4
|
+
<%#= link_to raw("← Back"), rails_performance_path, class: "back_link" %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<div class="card">
|
8
|
+
<div class="card-content">
|
9
|
+
<h2 class="subtitle">Grape Throughput Report</h2>
|
10
|
+
<div id="throughput_report_chart" class="chart"></div>
|
11
|
+
<p class="content is-small"></p>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<br/>
|
16
|
+
|
17
|
+
<div class="card">
|
18
|
+
<div class="card-content">
|
19
|
+
<h2 class="subtitle">Recent Requests (last <%= RailsPerformance::Reports::RecentRequestsReport::TIME_WINDOW / 60 %> minutes)<h2>
|
20
|
+
|
21
|
+
<table class="table is-fullwidth is-hoverable is-narrow">
|
22
|
+
<thead>
|
23
|
+
<tr>
|
24
|
+
<th data-sort="string">Datetime</th>
|
25
|
+
<th data-sort="string">Method</th>
|
26
|
+
<th data-sort="string">Path</th>
|
27
|
+
<th data-sort="string">Status</th>
|
28
|
+
<th data-sort="float">endpoint_render.grape</th>
|
29
|
+
<th data-sort="float">format_response.grape</th>
|
30
|
+
<th data-sort="float">endpoint_run.grape</th>
|
31
|
+
<th></th>
|
32
|
+
</tr>
|
33
|
+
</thead>
|
34
|
+
<tbody>
|
35
|
+
<% if @recent_report_data.empty? %>
|
36
|
+
<tr>
|
37
|
+
<td colspan="10">Nothing to show here. Try to make a few requests in the main app.</td>
|
38
|
+
</tr>
|
39
|
+
<% end %>
|
40
|
+
<% @recent_report_data.each do |e| %>
|
41
|
+
<tr>
|
42
|
+
<td><%= format_datetime e[:datetime] %></td>
|
43
|
+
<td><%= e[:method] %></td>
|
44
|
+
<td><%= e[:path] %></td>
|
45
|
+
<td><%= status_tag e[:status] %></td>
|
46
|
+
<td class="nowrap"><%= ms e["endpoint_render.grape"] %></td>
|
47
|
+
<td class="nowrap"><%= ms e["format_response.grape"] %></td>
|
48
|
+
<td class="nowrap">
|
49
|
+
<%= ms e["endpoint_run.grape"] %>
|
50
|
+
</td>
|
51
|
+
</tr>
|
52
|
+
<% end %>
|
53
|
+
</tbody>
|
54
|
+
</table>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
<% content_for :on_load do %>
|
60
|
+
<script>
|
61
|
+
var data1 = <%= raw @throughput_report_data.to_json %>;
|
62
|
+
showTIRChart('throughput_report_chart', data1, ' requests / minute', 'Requests');
|
63
|
+
</script>
|
64
|
+
<% end %>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<title>Rake</title>
|
2
|
+
|
3
|
+
<% unless @datasource.default? %>
|
4
|
+
<%#= link_to raw("← Back"), rails_performance_path, class: "back_link" %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<div class="card">
|
8
|
+
<div class="card-content">
|
9
|
+
<h2 class="subtitle">Recent Rake tasks (last <%= RailsPerformance::Reports::RecentRequestsReport::TIME_WINDOW / 60 %> minutes)<h2>
|
10
|
+
|
11
|
+
<table class="table is-fullwidth is-hoverable is-narrow">
|
12
|
+
<thead>
|
13
|
+
<tr>
|
14
|
+
<th data-sort="string">Datetime</th>
|
15
|
+
<th data-sort="string">Details</th>
|
16
|
+
<th data-sort="float">Duration</th>
|
17
|
+
<th data-sort="string">Status</th>
|
18
|
+
</tr>
|
19
|
+
</thead>
|
20
|
+
<tbody>
|
21
|
+
<% if @recent_report_data.empty? %>
|
22
|
+
<tr>
|
23
|
+
<td colspan="10">Nothing to show here. Try to make a few requests in the main app.</td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
<% @recent_report_data.each do |e| %>
|
27
|
+
<tr>
|
28
|
+
<td><%= format_datetime e[:datetime] %></td>
|
29
|
+
<td>[<%= e[:task].join(" ") %>]</td>
|
30
|
+
<td class="nowrap"><%= ms e[:duration] %></td>
|
31
|
+
<td><%= status_tag e[:status] %></td>
|
32
|
+
</tr>
|
33
|
+
<% end %>
|
34
|
+
</tbody>
|
35
|
+
</table>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<br/>
|
40
|
+
|
41
|
+
<div class="card">
|
42
|
+
<div class="card-content">
|
43
|
+
<h2 class="subtitle">Rake Throughput Report</h2>
|
44
|
+
<div id="throughput_report_chart" class="chart"></div>
|
45
|
+
<p class="content is-small">All rake tasks in the application</p>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
|
50
|
+
<% content_for :on_load do %>
|
51
|
+
<script>
|
52
|
+
var data1 = <%= raw @throughput_report_data.to_json %>;
|
53
|
+
showTIRChart('throughput_report_chart', data1, ' tasks / minute', 'Tasks');
|
54
|
+
</script>
|
55
|
+
<% end %>
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<title>Recent Requests</title>
|
2
|
+
|
1
3
|
<div class="card">
|
2
4
|
<div class="card-content">
|
3
5
|
<h2 class="subtitle">Recent Requests (last <%= RailsPerformance::Reports::RecentRequestsReport::TIME_WINDOW / 60 %> minutes)<h2>
|
@@ -21,7 +23,7 @@
|
|
21
23
|
<tbody>
|
22
24
|
<% if @data.empty? %>
|
23
25
|
<tr>
|
24
|
-
<td colspan="10">Nothing to show here. Try to make a few requests in main app.</td>
|
26
|
+
<td colspan="10">Nothing to show here. Try to make a few requests in the main app.</td>
|
25
27
|
</tr>
|
26
28
|
<% end %>
|
27
29
|
<% @data.each do |e| %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<title>
|
1
|
+
<title>Sidekiq</title>
|
2
2
|
|
3
3
|
<% unless @datasource.default? %>
|
4
4
|
<%#= link_to raw("← Back"), rails_performance_path, class: "back_link" %>
|
@@ -22,6 +22,8 @@
|
|
22
22
|
</div>
|
23
23
|
</div>
|
24
24
|
|
25
|
+
<br/>
|
26
|
+
|
25
27
|
<div class="card">
|
26
28
|
<div class="card-content">
|
27
29
|
<h2 class="subtitle">Recent Jobs (last <%= RailsPerformance::Reports::RecentRequestsReport::TIME_WINDOW / 60 %> minutes)<h2>
|
@@ -36,13 +38,12 @@
|
|
36
38
|
<th data-sort="string">Status</th>
|
37
39
|
<th data-sort="float">Duration</th>
|
38
40
|
<th>Message</th>
|
39
|
-
<th></th>
|
40
41
|
</tr>
|
41
42
|
</thead>
|
42
43
|
<tbody>
|
43
44
|
<% if @recent_report_data.empty? %>
|
44
45
|
<tr>
|
45
|
-
<td colspan="10">Nothing to show here. Try to make a few requests in main app.</td>
|
46
|
+
<td colspan="10">Nothing to show here. Try to make a few requests in the main app.</td>
|
46
47
|
</tr>
|
47
48
|
<% end %>
|
48
49
|
<% @recent_report_data.each do |e| %>
|
@@ -53,7 +54,7 @@
|
|
53
54
|
<td><%= e[:jid] %></td>
|
54
55
|
<td><%= status_tag e[:status] %></td>
|
55
56
|
<td class="nowrap"><%= ms e[:duration] %></td>
|
56
|
-
<td><%= e[:message] %></td>
|
57
|
+
<td><%= e[:message].presence || '-' %></td>
|
57
58
|
</tr>
|
58
59
|
<% end %>
|
59
60
|
</tbody>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
window.panel.header.html(window.panel.close + '<%= j report_name(@datasource.q) %>');
|
2
|
-
window.panel.content.html("<%= j render '/rails_performance/rails_performance/summary' %>");
|
2
|
+
window.panel.content.html("<%= j render '/rails_performance/rails_performance/summary', title: "Requests" %>");
|
3
3
|
|
4
4
|
var data1 = <%= raw @throughput_report_data.to_json %>;
|
5
5
|
showTIRChart('throughput_report_chart_mini', data1, ' rpm', 'RPM');
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if @record %>
|
2
|
-
window.panel.header.html(window.panel.close + "<%= j report_name(@record.
|
2
|
+
window.panel.header.html(window.panel.close + "<%= j report_name(@record.record_hash) %>");
|
3
3
|
<% else %>
|
4
4
|
window.panel.header.html(window.panel.close);
|
5
5
|
<% end %>
|
@@ -19,8 +19,16 @@
|
|
19
19
|
<%= link_to '500 Errors', rails_performance.rails_performance_crashes_url, class: "navbar-item #{active?(:crashes)}" %>
|
20
20
|
<%= link_to 'Recent Requests', rails_performance.rails_performance_recent_url, class: "navbar-item #{active?(:recent)}" %>
|
21
21
|
<% if defined?(Sidekiq) %>
|
22
|
-
<%= link_to 'Sidekiq', rails_performance.
|
22
|
+
<%= link_to 'Sidekiq', rails_performance.rails_performance_sidekiq_url, class: "navbar-item #{active?(:sidekiq)}" %>
|
23
23
|
<% end %>
|
24
|
+
<% if defined?(Delayed::Job) %>
|
25
|
+
<%= link_to 'Delayed::Job', rails_performance.rails_performance_delayed_job_url, class: "navbar-item #{active?(:delayed_job)}" %>
|
26
|
+
<% end %>
|
27
|
+
<% if defined?(Grape) %>
|
28
|
+
<%= link_to 'Grape', rails_performance.rails_performance_grape_url, class: "navbar-item #{active?(:grape)}" %>
|
29
|
+
<% end %>
|
30
|
+
<%= link_to 'Rake', rails_performance.rails_performance_rake_url, class: "navbar-item #{active?(:rake)}" %>
|
31
|
+
<%= link_to 'Custom Events', rails_performance.rails_performance_custom_url, class: "navbar-item #{active?(:custom)}" %>
|
24
32
|
</div>
|
25
33
|
|
26
34
|
<div class="navbar-end">
|
@@ -36,6 +36,11 @@
|
|
36
36
|
opacity: 0.7;
|
37
37
|
}
|
38
38
|
|
39
|
+
.footer-box a {
|
40
|
+
color: #4a4a4a;
|
41
|
+
text-decoration: underline;
|
42
|
+
}
|
43
|
+
|
39
44
|
.stats_icon svg {
|
40
45
|
width: 16px;
|
41
46
|
height: 16px;
|
@@ -79,4 +84,8 @@
|
|
79
84
|
|
80
85
|
table th[data-sort] {
|
81
86
|
cursor: pointer;
|
87
|
+
}
|
88
|
+
|
89
|
+
.very-small-text {
|
90
|
+
font-size: 8px;
|
82
91
|
}
|
data/config/routes.rb
CHANGED
@@ -8,7 +8,11 @@ RailsPerformance::Engine.routes.draw do
|
|
8
8
|
get '/trace/:id' => 'rails_performance#trace', as: :rails_performance_trace
|
9
9
|
get '/summary' => 'rails_performance#summary', as: :rails_performance_summary
|
10
10
|
|
11
|
-
get '/
|
11
|
+
get '/sidekiq' => 'rails_performance#sidekiq', as: :rails_performance_sidekiq
|
12
|
+
get '/delayed_job'=> 'rails_performance#delayed_job', as: :rails_performance_delayed_job
|
13
|
+
get '/grape' => 'rails_performance#grape', as: :rails_performance_grape
|
14
|
+
get '/rake' => 'rails_performance#rake', as: :rails_performance_rake
|
15
|
+
get '/custom' => 'rails_performance#custom', as: :rails_performance_custom
|
12
16
|
end
|
13
17
|
|
14
18
|
Rails.application.routes.draw do
|
data/lib/rails_performance.rb
CHANGED
@@ -3,10 +3,15 @@ require "redis-namespace"
|
|
3
3
|
require_relative "./rails_performance/version.rb"
|
4
4
|
require_relative "rails_performance/rails/query_builder.rb"
|
5
5
|
require_relative "rails_performance/rails/middleware.rb"
|
6
|
-
require_relative "rails_performance/data_source.rb"
|
7
6
|
require_relative "rails_performance/models/base_record.rb"
|
8
|
-
require_relative "rails_performance/models/
|
9
|
-
require_relative "rails_performance/models/
|
7
|
+
require_relative "rails_performance/models/request_record.rb"
|
8
|
+
require_relative "rails_performance/models/sidekiq_record.rb"
|
9
|
+
require_relative "rails_performance/models/delayed_job_record.rb"
|
10
|
+
require_relative "rails_performance/models/grape_record.rb"
|
11
|
+
require_relative "rails_performance/models/trace_record.rb"
|
12
|
+
require_relative "rails_performance/models/rake_record.rb"
|
13
|
+
require_relative "rails_performance/models/custom_record.rb"
|
14
|
+
require_relative "rails_performance/data_source.rb"
|
10
15
|
require_relative "rails_performance/utils.rb"
|
11
16
|
require_relative "rails_performance/reports/base_report.rb"
|
12
17
|
require_relative "rails_performance/reports/requests_report.rb"
|
@@ -16,14 +21,14 @@ require_relative "rails_performance/reports/throughput_report.rb"
|
|
16
21
|
require_relative "rails_performance/reports/recent_requests_report.rb"
|
17
22
|
require_relative "rails_performance/reports/breakdown_report.rb"
|
18
23
|
require_relative "rails_performance/reports/trace_report.rb"
|
19
|
-
require_relative "rails_performance/extensions/
|
20
|
-
require_relative "rails_performance/
|
24
|
+
require_relative "rails_performance/extensions/trace.rb"
|
25
|
+
require_relative "rails_performance/thread/current_request.rb"
|
21
26
|
|
22
27
|
module RailsPerformance
|
23
28
|
FORMAT = "%Y%m%dT%H%M"
|
24
29
|
|
25
30
|
mattr_accessor :redis
|
26
|
-
@@redis = Redis::Namespace.new("#{::Rails.env}-rails-performance", redis: Redis.new)
|
31
|
+
@@redis = Redis::Namespace.new("{#{::Rails.env}-rails-performance}", redis: Redis.new)
|
27
32
|
|
28
33
|
mattr_accessor :duration
|
29
34
|
@@duration = 4.hours
|
@@ -60,12 +65,28 @@ module RailsPerformance
|
|
60
65
|
end
|
61
66
|
@@ignored_endpoints = []
|
62
67
|
|
63
|
-
|
68
|
+
# skip requests if it's inside Rails Performance view
|
69
|
+
mattr_accessor :skip
|
70
|
+
@@skip = false
|
71
|
+
|
72
|
+
def RailsPerformance.setup
|
64
73
|
yield(self)
|
65
74
|
end
|
66
75
|
|
67
|
-
|
76
|
+
def RailsPerformance.log(message)
|
77
|
+
return
|
68
78
|
|
69
|
-
|
79
|
+
if ::Rails.logger
|
80
|
+
# puts(message)
|
81
|
+
::Rails.logger.debug(message)
|
82
|
+
else
|
83
|
+
puts(message)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
70
88
|
|
71
89
|
require "rails_performance/engine"
|
90
|
+
|
91
|
+
require_relative './rails_performance/gems/custom_ext.rb'
|
92
|
+
RailsPerformance.send :extend, RailsPerformance::Gems::CustomExtension
|
@@ -1,20 +1,27 @@
|
|
1
1
|
module RailsPerformance
|
2
2
|
class DataSource
|
3
|
+
KLASSES = {
|
4
|
+
requests: RailsPerformance::Models::RequestRecord,
|
5
|
+
sidekiq: RailsPerformance::Models::SidekiqRecord,
|
6
|
+
delayed_job: RailsPerformance::Models::DelayedJobRecord,
|
7
|
+
grape: RailsPerformance::Models::GrapeRecord,
|
8
|
+
rake: RailsPerformance::Models::RakeRecord,
|
9
|
+
custom: RailsPerformance::Models::CustomRecord,
|
10
|
+
}
|
11
|
+
|
3
12
|
attr_reader :q, :klass, :type
|
4
13
|
|
5
|
-
def initialize(q: {}, type
|
6
|
-
@klass = klass
|
14
|
+
def initialize(q: {}, type:)
|
7
15
|
@type = type
|
16
|
+
@klass = KLASSES[type]
|
8
17
|
q[:on] ||= Date.today
|
9
18
|
@q = q
|
10
|
-
|
11
|
-
#puts " [DataSource Q] --> #{@q.inspect}\n\n"
|
12
19
|
end
|
13
20
|
|
14
21
|
def db
|
15
|
-
result =
|
16
|
-
(
|
17
|
-
|
22
|
+
result = RailsPerformance::Models::Collection.new
|
23
|
+
(RailsPerformance::Utils.days + 1).times do |e|
|
24
|
+
RailsPerformance::DataSource.new(q: self.q.merge({ on: e.days.ago.to_date }), type: type).add_to(result)
|
18
25
|
end
|
19
26
|
result
|
20
27
|
end
|
@@ -23,7 +30,7 @@ module RailsPerformance
|
|
23
30
|
@q.keys == [:on]
|
24
31
|
end
|
25
32
|
|
26
|
-
def add_to(storage =
|
33
|
+
def add_to(storage = RailsPerformance::Models::Collection.new)
|
27
34
|
store do |record|
|
28
35
|
storage.add(record)
|
29
36
|
end
|
@@ -36,7 +43,7 @@ module RailsPerformance
|
|
36
43
|
return [] if keys.blank?
|
37
44
|
|
38
45
|
keys.each_with_index do |key, index|
|
39
|
-
yield klass.
|
46
|
+
yield klass.from_db(key, values[index])
|
40
47
|
end
|
41
48
|
end
|
42
49
|
|
@@ -45,9 +52,17 @@ module RailsPerformance
|
|
45
52
|
def query
|
46
53
|
case type
|
47
54
|
when :requests
|
48
|
-
"performance|*#{compile_requests_query}*|END"
|
49
|
-
when :
|
50
|
-
"
|
55
|
+
"performance|*#{compile_requests_query}*|END|#{RailsPerformance::SCHEMA}"
|
56
|
+
when :sidekiq
|
57
|
+
"sidekiq|*#{compile_sidekiq_query}*|END|#{RailsPerformance::SCHEMA}"
|
58
|
+
when :delayed_job
|
59
|
+
"delayed_job|*#{compile_delayed_job_query}*|END|#{RailsPerformance::SCHEMA}"
|
60
|
+
when :grape
|
61
|
+
"grape|*#{compile_grape_query}*|END|#{RailsPerformance::SCHEMA}"
|
62
|
+
when :rake
|
63
|
+
"rake|*#{compile_rake_query}*|END|#{RailsPerformance::SCHEMA}"
|
64
|
+
when :custom
|
65
|
+
"custom|*#{compile_custom_query}*|END|#{RailsPerformance::SCHEMA}"
|
51
66
|
else
|
52
67
|
raise "wrong type for datasource query builder"
|
53
68
|
end
|
@@ -55,7 +70,6 @@ module RailsPerformance
|
|
55
70
|
|
56
71
|
def compile_requests_query
|
57
72
|
str = []
|
58
|
-
|
59
73
|
str << "controller|#{q[:controller]}|" if q[:controller].present?
|
60
74
|
str << "action|#{q[:action]}|" if q[:action].present?
|
61
75
|
str << "format|#{q[:format]}|" if q[:format].present?
|
@@ -63,18 +77,43 @@ module RailsPerformance
|
|
63
77
|
str << "datetime|#{q[:on].strftime('%Y%m%d')}*|" if q[:on].present?
|
64
78
|
str << "method|#{q[:method]}|" if q[:method].present?
|
65
79
|
str << "path|#{q[:path]}|" if q[:path].present?
|
66
|
-
|
67
80
|
str.join("*")
|
68
81
|
end
|
69
82
|
|
70
|
-
def
|
83
|
+
def compile_sidekiq_query
|
71
84
|
str = []
|
72
|
-
|
73
85
|
str << "queue|#{q[:queue]}|" if q[:queue].present?
|
74
86
|
str << "worker|#{q[:worker]}|" if q[:worker].present?
|
75
87
|
str << "datetime|#{q[:on].strftime('%Y%m%d')}*|" if q[:on].present?
|
76
88
|
str << "status|#{q[:status]}|" if q[:status].present?
|
89
|
+
str.join("*")
|
90
|
+
end
|
91
|
+
|
92
|
+
def compile_delayed_job_query
|
93
|
+
str = []
|
94
|
+
str << "datetime|#{q[:on].strftime('%Y%m%d')}*|" if q[:on].present?
|
95
|
+
str << "status|#{q[:status]}|" if q[:status].present?
|
96
|
+
str.join("*")
|
97
|
+
end
|
98
|
+
|
99
|
+
def compile_rake_query
|
100
|
+
str = []
|
101
|
+
str << "datetime|#{q[:on].strftime('%Y%m%d')}*|" if q[:on].present?
|
102
|
+
str << "status|#{q[:status]}|" if q[:status].present?
|
103
|
+
str.join("*")
|
104
|
+
end
|
105
|
+
|
106
|
+
def compile_custom_query
|
107
|
+
str = []
|
108
|
+
str << "datetime|#{q[:on].strftime('%Y%m%d')}*|" if q[:on].present?
|
109
|
+
str << "status|#{q[:status]}|" if q[:status].present?
|
110
|
+
str.join("*")
|
111
|
+
end
|
77
112
|
|
113
|
+
def compile_grape_query
|
114
|
+
str = []
|
115
|
+
str << "datetime|#{q[:on].strftime('%Y%m%d')}*|" if q[:on].present?
|
116
|
+
str << "status|#{q[:status]}|" if q[:status].present?
|
78
117
|
str.join("*")
|
79
118
|
end
|
80
119
|
|