rails_performance 1.3.1 → 1.3.3
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 +13 -1
- data/app/controllers/rails_performance/rails_performance_controller.rb +14 -36
- data/app/views/rails_performance/layouts/rails_performance.html.erb +23 -11
- data/app/views/rails_performance/rails_performance/requests.html.erb +1 -1
- data/app/views/rails_performance/rails_performance/trace.js.erb +1 -1
- data/app/views/rails_performance/shared/_header.html.erb +1 -1
- data/app/views/rails_performance/stylesheets/style.css +17 -2
- data/lib/generators/rails_performance/install/templates/initializer.rb +2 -2
- data/lib/rails_performance/models/request_record.rb +6 -2
- data/lib/rails_performance/reports/percentile_report.rb +1 -1
- data/lib/rails_performance/reports/requests_report.rb +1 -1
- data/lib/rails_performance/version.rb +1 -1
- data/lib/rails_performance.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a55d30b55b9b21648f47e913b5fc80277338d64265c4b652dd7c3b66080f7a2
|
4
|
+
data.tar.gz: d402afddcd43f8328dcb12b4749657d4ed2e60159722a73524cf81aa3b91dff3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7497bf5420d086bb8ea1f18cee0ff029f50d5df03065f3866456560912f4cb07207c1abeb94a1c3df0f117df083e24cc118938012241f911631e5bfff0868751
|
7
|
+
data.tar.gz: 895b554629a924b4afcfb7c3e1b18126ec7e56bad780f1a95d8ab3a80bd2e8dcb17ee5782b6566d930e0937770e00d8624d5a04960de65e5021841455f9085c2
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ Create `config/initializers/rails_performance.rb` in your app:
|
|
51
51
|
|
52
52
|
```ruby
|
53
53
|
RailsPerformance.setup do |config|
|
54
|
-
config.redis = Redis
|
54
|
+
config.redis = Redis.new(url: ENV["REDIS_URL"].presence || "redis://127.0.0.1:6379/0") # or Redis::Namespace.new("rails-performance", redis: Redis.new), see below in README
|
55
55
|
config.duration = 4.hours
|
56
56
|
|
57
57
|
config.debug = false # currently not used>
|
@@ -173,6 +173,18 @@ RailsPerformance.measure("some label", "some namespace") do
|
|
173
173
|
end
|
174
174
|
```
|
175
175
|
|
176
|
+
## Using with Rails Namespace
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
config.redis = Redis::Namespace.new("#{Rails.env}-rails-performance", redis: Redis.new(url: ENV["REDIS_URL"].presence || "redis://127.0.0.1:6379/0"))
|
180
|
+
```
|
181
|
+
|
182
|
+
and add a gem dependency to the Gemfile:
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
gem 'redis-namespace'
|
186
|
+
```
|
187
|
+
|
176
188
|
## How it works
|
177
189
|
|
178
190
|

|
@@ -6,9 +6,7 @@ module RailsPerformance
|
|
6
6
|
|
7
7
|
if RailsPerformance.enabled
|
8
8
|
def index
|
9
|
-
@datasource = RailsPerformance::DataSource.new(
|
10
|
-
**prepare_query, type: :requests
|
11
|
-
)
|
9
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :requests)
|
12
10
|
db = @datasource.db
|
13
11
|
|
14
12
|
@throughput_report_data = RailsPerformance::Reports::ThroughputReport.new(db).data
|
@@ -17,16 +15,12 @@ module RailsPerformance
|
|
17
15
|
end
|
18
16
|
|
19
17
|
def summary
|
20
|
-
@datasource = RailsPerformance::DataSource.new(
|
21
|
-
**prepare_query, type: :requests
|
22
|
-
)
|
18
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :requests)
|
23
19
|
db = @datasource.db
|
24
20
|
|
25
21
|
@throughput_report_data = RailsPerformance::Reports::ThroughputReport.new(db).data
|
26
22
|
@response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
|
27
|
-
@data = RailsPerformance::Reports::BreakdownReport.new(
|
28
|
-
db, title: "Requests"
|
29
|
-
).data
|
23
|
+
@data = RailsPerformance::Reports::BreakdownReport.new(db, title: "Requests").data
|
30
24
|
respond_to do |format|
|
31
25
|
format.js {}
|
32
26
|
format.any do
|
@@ -47,9 +41,7 @@ module RailsPerformance
|
|
47
41
|
end
|
48
42
|
|
49
43
|
def crashes
|
50
|
-
@datasource = RailsPerformance::DataSource.new(
|
51
|
-
**prepare_query({status_eq: 500}), type: :requests
|
52
|
-
)
|
44
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query({status_eq: 500}), type: :requests)
|
53
45
|
db = @datasource.db
|
54
46
|
@data = RailsPerformance::Reports::CrashReport.new(db).data
|
55
47
|
|
@@ -62,11 +54,9 @@ module RailsPerformance
|
|
62
54
|
end
|
63
55
|
|
64
56
|
def requests
|
65
|
-
@datasource = RailsPerformance::DataSource.new(**prepare_query,
|
66
|
-
type: :requests)
|
57
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :requests)
|
67
58
|
db = @datasource.db
|
68
|
-
@data = RailsPerformance::Reports::RequestsReport.new(db,
|
69
|
-
group: :controller_action_format, sort: :count).data
|
59
|
+
@data = RailsPerformance::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :count).data
|
70
60
|
respond_to do |format|
|
71
61
|
format.html
|
72
62
|
format.csv do
|
@@ -76,8 +66,7 @@ type: :requests)
|
|
76
66
|
end
|
77
67
|
|
78
68
|
def recent
|
79
|
-
@datasource = RailsPerformance::DataSource.new(**prepare_query,
|
80
|
-
type: :requests)
|
69
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :requests)
|
81
70
|
db = @datasource.db
|
82
71
|
@data = RailsPerformance::Reports::RecentRequestsReport.new(db).data(params[:from_timei])
|
83
72
|
|
@@ -110,8 +99,7 @@ type: :requests)
|
|
110
99
|
end
|
111
100
|
|
112
101
|
def slow
|
113
|
-
@datasource = RailsPerformance::DataSource.new(**prepare_query,
|
114
|
-
type: :requests)
|
102
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :requests)
|
115
103
|
db = @datasource.db
|
116
104
|
@data = RailsPerformance::Reports::SlowRequestsReport.new(db).data
|
117
105
|
|
@@ -124,9 +112,7 @@ type: :requests)
|
|
124
112
|
end
|
125
113
|
|
126
114
|
def sidekiq
|
127
|
-
@datasource = RailsPerformance::DataSource.new(
|
128
|
-
**prepare_query, type: :sidekiq
|
129
|
-
)
|
115
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :sidekiq)
|
130
116
|
db = @datasource.db
|
131
117
|
@throughput_report_data = RailsPerformance::Reports::ThroughputReport.new(db).data
|
132
118
|
@response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
|
@@ -134,9 +120,7 @@ type: :requests)
|
|
134
120
|
end
|
135
121
|
|
136
122
|
def delayed_job
|
137
|
-
@datasource = RailsPerformance::DataSource.new(
|
138
|
-
**prepare_query, type: :delayed_job
|
139
|
-
)
|
123
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :delayed_job)
|
140
124
|
db = @datasource.db
|
141
125
|
@throughput_report_data = RailsPerformance::Reports::ThroughputReport.new(db).data
|
142
126
|
@response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
|
@@ -144,9 +128,7 @@ type: :requests)
|
|
144
128
|
end
|
145
129
|
|
146
130
|
def custom
|
147
|
-
@datasource = RailsPerformance::DataSource.new(
|
148
|
-
**prepare_query, type: :custom
|
149
|
-
)
|
131
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :custom)
|
150
132
|
db = @datasource.db
|
151
133
|
@throughput_report_data = RailsPerformance::Reports::ThroughputReport.new(db).data
|
152
134
|
@response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
|
@@ -154,18 +136,14 @@ type: :requests)
|
|
154
136
|
end
|
155
137
|
|
156
138
|
def grape
|
157
|
-
@datasource = RailsPerformance::DataSource.new(
|
158
|
-
**prepare_query, type: :grape
|
159
|
-
)
|
139
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :grape)
|
160
140
|
db = @datasource.db
|
161
141
|
@throughput_report_data = RailsPerformance::Reports::ThroughputReport.new(db).data
|
162
142
|
@recent_report_data = RailsPerformance::Reports::RecentRequestsReport.new(db).data
|
163
143
|
end
|
164
144
|
|
165
145
|
def rake
|
166
|
-
@datasource = RailsPerformance::DataSource.new(
|
167
|
-
**prepare_query, type: :rake
|
168
|
-
)
|
146
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :rake)
|
169
147
|
db = @datasource.db
|
170
148
|
@throughput_report_data = RailsPerformance::Reports::ThroughputReport.new(db).data
|
171
149
|
@recent_report_data = RailsPerformance::Reports::RecentRequestsReport.new(db).data
|
@@ -173,7 +151,7 @@ type: :requests)
|
|
173
151
|
|
174
152
|
private
|
175
153
|
|
176
|
-
def prepare_query(query
|
154
|
+
def prepare_query(query)
|
177
155
|
RailsPerformance::Rails::QueryBuilder.compose_from(query)
|
178
156
|
end
|
179
157
|
end
|
@@ -9,24 +9,36 @@
|
|
9
9
|
<%= render '/rails_performance/stylesheets/stylesheets' %>
|
10
10
|
<link rel="shortcut icon" href="/favicon.ico">
|
11
11
|
</head>
|
12
|
-
|
12
|
+
|
13
|
+
<body class="has-sticky-footer">
|
13
14
|
<div class="loader-wrapper">
|
14
15
|
<div class="loader is-loading"></div>
|
15
16
|
</div>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<div class="is-pulled-right">v.<%= RailsPerformance::VERSION %></div>
|
17
|
+
|
18
|
+
<div class="main-content">
|
19
|
+
<section class="section">
|
20
|
+
<div class="container is-fluid is-size-7">
|
21
|
+
<%= render '/rails_performance/shared/header' %>
|
22
|
+
<%= yield %>
|
23
23
|
</div>
|
24
|
+
</section>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<footer class="footer footer-box">
|
28
|
+
<div class="container is-fluid is-size-7">
|
29
|
+
© Rails Performance <span class='red'><i class="fas fa-heart"></i></span>
|
30
|
+
<%= link_to 'https://github.com/igorkasyanchuk/rails_performance', 'https://github.com/igorkasyanchuk/rails_performance', target: '_blank' %>
|
31
|
+
<div class="is-pulled-right">v.<%= RailsPerformance::VERSION %></div>
|
24
32
|
</div>
|
25
|
-
</
|
33
|
+
</footer>
|
34
|
+
|
26
35
|
<%= render '/rails_performance/panel' %>
|
27
|
-
|
36
|
+
|
37
|
+
<div class="panel-overlay"></div>
|
38
|
+
|
28
39
|
<%= render '/rails_performance/javascripts/javascripts' %>
|
29
|
-
<%= yield :on_load %>
|
30
40
|
|
41
|
+
<%= yield :on_load %>
|
31
42
|
</body>
|
43
|
+
|
32
44
|
</html>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if @record %>
|
2
|
-
window.panel.header.html(window.panel.close + "<%= j report_name(@record.record_hash) %>");
|
2
|
+
window.panel.header.html(window.panel.close + "<%= j report_name(@record.record_hash.with_indifferent_access.except(*RailsPerformance.ignore_trace_headers)) %>");
|
3
3
|
<% else %>
|
4
4
|
window.panel.header.html(window.panel.close);
|
5
5
|
<% end %>
|
@@ -16,9 +16,9 @@
|
|
16
16
|
<div class="navbar-start">
|
17
17
|
<%= link_to 'Dashboard', rails_performance.rails_performance_url, class: "navbar-item #{active?(:dashboard)}" %>
|
18
18
|
<%= link_to 'Requests Analysis', rails_performance.rails_performance_requests_url, class: "navbar-item #{active?(:requests)}" %>
|
19
|
-
<%= link_to '500 Errors', rails_performance.rails_performance_crashes_url, class: "navbar-item #{active?(:crashes)}" %>
|
20
19
|
<%= link_to 'Recent Requests', rails_performance.rails_performance_recent_url, class: "navbar-item #{active?(:recent)}" %>
|
21
20
|
<%= link_to 'Slow Requests', rails_performance.rails_performance_slow_url, class: "navbar-item #{active?(:slow)}" %>
|
21
|
+
<%= link_to '500 Errors', rails_performance.rails_performance_crashes_url, class: "navbar-item #{active?(:crashes)}" %>
|
22
22
|
<% if defined?(Sidekiq) %>
|
23
23
|
<%= link_to 'Sidekiq', rails_performance.rails_performance_sidekiq_url, class: "navbar-item #{active?(:sidekiq)}" %>
|
24
24
|
<% end %>
|
@@ -72,11 +72,11 @@
|
|
72
72
|
}
|
73
73
|
|
74
74
|
.chart {
|
75
|
-
height:
|
75
|
+
height: 300px;
|
76
76
|
}
|
77
77
|
|
78
78
|
.chart_mini {
|
79
|
-
height:
|
79
|
+
height: 200px;
|
80
80
|
width: 720px;
|
81
81
|
}
|
82
82
|
|
@@ -125,3 +125,18 @@ table th[data-sort] {
|
|
125
125
|
.attention {
|
126
126
|
background-color: #f6f5f5;
|
127
127
|
}
|
128
|
+
|
129
|
+
body.has-sticky-footer {
|
130
|
+
display: flex;
|
131
|
+
min-height: 100vh;
|
132
|
+
flex-direction: column;
|
133
|
+
}
|
134
|
+
|
135
|
+
.main-content {
|
136
|
+
flex: 1;
|
137
|
+
}
|
138
|
+
|
139
|
+
.footer-box {
|
140
|
+
background-color: #f5f5f5;
|
141
|
+
padding: 1rem 0;
|
142
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
if defined?(RailsPerformance)
|
2
2
|
RailsPerformance.setup do |config|
|
3
3
|
# Redis configuration
|
4
|
-
config.redis = Redis
|
4
|
+
config.redis = Redis.new(url: ENV["REDIS_URL"].presence || "redis://127.0.0.1:6379/0")
|
5
5
|
|
6
6
|
# All data we collect
|
7
7
|
config.duration = 4.hours
|
@@ -36,7 +36,7 @@ if defined?(RailsPerformance)
|
|
36
36
|
|
37
37
|
# You can ignore request paths by specifying the beginning of the path.
|
38
38
|
# For example, all routes starting with '/admin' can be ignored:
|
39
|
-
config.ignored_paths = [
|
39
|
+
config.ignored_paths = ["/rails/performance"]
|
40
40
|
|
41
41
|
# store custom data for the request
|
42
42
|
# config.custom_data_proc = proc do |env|
|
@@ -30,7 +30,11 @@ module RailsPerformance
|
|
30
30
|
def self.from_db(key, value)
|
31
31
|
items = key.split("|")
|
32
32
|
|
33
|
-
parsed_value =
|
33
|
+
parsed_value = begin
|
34
|
+
JSON.parse(value)
|
35
|
+
rescue
|
36
|
+
{}
|
37
|
+
end
|
34
38
|
|
35
39
|
RequestRecord.new(
|
36
40
|
controller: items[2],
|
@@ -45,7 +49,7 @@ module RailsPerformance
|
|
45
49
|
json: value,
|
46
50
|
duration: parsed_value["duration"],
|
47
51
|
view_runtime: parsed_value["view_runtime"],
|
48
|
-
db_runtime: parsed_value["db_runtime"]
|
52
|
+
db_runtime: parsed_value["db_runtime"]
|
49
53
|
)
|
50
54
|
end
|
51
55
|
|
@@ -2,7 +2,7 @@ module RailsPerformance
|
|
2
2
|
module Reports
|
3
3
|
class PercentileReport < BaseReport
|
4
4
|
def data
|
5
|
-
durations = db.data.collect(&:duration)
|
5
|
+
durations = db.data.collect(&:duration).compact
|
6
6
|
{
|
7
7
|
p50: RailsPerformance::Utils.percentile(durations, 50),
|
8
8
|
p95: RailsPerformance::Utils.percentile(durations, 95),
|
@@ -21,7 +21,7 @@ module RailsPerformance
|
|
21
21
|
db_runtime_slowest: db_runtimes.max,
|
22
22
|
p50_duration: RailsPerformance::Utils.percentile(durations, 50),
|
23
23
|
p95_duration: RailsPerformance::Utils.percentile(durations, 95),
|
24
|
-
p99_duration: RailsPerformance::Utils.percentile(durations, 99)
|
24
|
+
p99_duration: RailsPerformance::Utils.percentile(durations, 99)
|
25
25
|
}
|
26
26
|
end.sort_by { |e| -e[sort].to_f } # to_f because could ne NaN or nil
|
27
27
|
end
|
data/lib/rails_performance.rb
CHANGED
@@ -113,6 +113,10 @@ module RailsPerformance
|
|
113
113
|
mattr_accessor :include_custom_events
|
114
114
|
@@include_custom_events = true
|
115
115
|
|
116
|
+
# Trace details view configuration
|
117
|
+
mattr_accessor :ignore_trace_headers
|
118
|
+
@@ignore_trace_headers = ["datetimei"]
|
119
|
+
|
116
120
|
def self.setup
|
117
121
|
yield(self)
|
118
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_performance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|