rails_performance 1.0.5.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dffe7a004722639d7873e77a300ca3b62ea1c03d539975170e48a2491892093d
4
- data.tar.gz: ca03875ff577f34febab9fd8c091557790412fb6b5e36bc43c82941340390a68
3
+ metadata.gz: 115679518abb747b5a5702a3383d86da4f969932146f00ef87339a66ab8b786b
4
+ data.tar.gz: 8ee6382599f9ef62ec222407d56a03adf085a63e3717cc489b0d81bc9392bd03
5
5
  SHA512:
6
- metadata.gz: b907a6c5ace84663b4527744434c062673140d30d002b0b036542f72b67db1cfba1421b7261148fa0ae4f001491f0123243d21e3f547eef2e96abb67f512c6a3
7
- data.tar.gz: 85eb799be2eaadc0025768eb648db63f2a935dec20c097a2f37aca1b943ee07080adda2a27ee91652eff6cb2f3f317855185d2349c01389953127349217a9f9c
6
+ metadata.gz: 34190351d34233c86da069a5728c7a504c55a1f8153d38da9e030b0702cb1c4fba55048d17f731e2be052d71e12d44a58b8dc8c8b2868d1cb7741560a7cd2651
7
+ data.tar.gz: d8f937d0c6e2094061fba53613558ef4c61a368ec09cf11d2169b3b353a88c6cc2ce9c053a5fd6be2b4ed1d1cb808cab8ec42bc55c3976fa012c7f4263cf2dc0
data/README.md CHANGED
@@ -14,6 +14,7 @@ This is a **simple and free alternative** to the New Relic APM, Datadog or other
14
14
  It allows you to track:
15
15
 
16
16
  - real-time monitoring on the Recent tab
17
+ - monitor slow requests
17
18
  - throughput report (see amount of RPM (requests per minute))
18
19
  - an average response time
19
20
  - the slowest controllers & actions
@@ -59,7 +60,12 @@ RailsPerformance.setup do |config|
59
60
 
60
61
  # configure Recent tab (time window and limit of requests)
61
62
  # config.recent_requests_time_window = 60.minutes
62
- # config.recent_requests_limit = nil
63
+ # config.recent_requests_limit = nil # or 1000
64
+
65
+ # configure Slow Requests tab (time window, limit of requests and threshold)
66
+ # config.slow_requests_time_window = 4.hours # time window for slow requests
67
+ # config.slow_requests_limit = 500 # number of max rows
68
+ # config.slow_requests_threshold = 500 # number of ms
63
69
 
64
70
  # default path where to mount gem,
65
71
  # alternatively you can mount the RailsPerformance::Engine in your routes.rb
@@ -61,6 +61,12 @@ module RailsPerformance
61
61
  end
62
62
  end
63
63
 
64
+ def slow
65
+ @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
66
+ db = @datasource.db
67
+ @data = RailsPerformance::Reports::SlowRequestsReport.new(db).data
68
+ end
69
+
64
70
  def sidekiq
65
71
  @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :sidekiq)
66
72
  db = @datasource.db
@@ -107,4 +113,4 @@ module RailsPerformance
107
113
  end
108
114
 
109
115
  end
110
- end
116
+ end
@@ -118,6 +118,8 @@ module RailsPerformance
118
118
  "is-active" if controller_name == "rails_performance" && action_name == "requests"
119
119
  when :recent
120
120
  "is-active" if controller_name == "rails_performance" && action_name == "recent"
121
+ when :slow
122
+ "is-active" if controller_name == "rails_performance" && action_name == "slow"
121
123
  when :sidekiq
122
124
  "is-active" if controller_name == "rails_performance" && action_name == "sidekiq"
123
125
  when :delayed_job
@@ -170,6 +170,17 @@ function showRTChart(div, data) {
170
170
  const recent = document.getElementById("recent")
171
171
  const autoupdate = document.getElementById("autoupdate")
172
172
 
173
+ if(autoupdate) {
174
+ // set autoupdate checked from localStorage is missing
175
+ if (localStorage.getItem("autoupdate") === null) {
176
+ localStorage.setItem("autoupdate", "true");
177
+ }
178
+ autoupdate.checked = localStorage.getItem("autoupdate") === "true";
179
+ autoupdate.addEventListener('change', () => {
180
+ localStorage.setItem("autoupdate", autoupdate.checked);
181
+ });
182
+ }
183
+
173
184
  if(recent) {
174
185
  const tbody = recent.querySelector("tbody")
175
186
 
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
  <div class="column right-text is-size-5 has-text-right">
10
10
  <label id="autoupdate_label">
11
- <input id="autoupdate" type="checkbox" checked/>
11
+ <input id="autoupdate" type="checkbox"/>
12
12
  Auto-update
13
13
  </label>
14
14
  </div>
@@ -0,0 +1,39 @@
1
+ <title>Slow Requests</title>
2
+
3
+ <div class="card">
4
+ <div class="card-content">
5
+ <div class="columns">
6
+ <div class="column">
7
+ <h2 class="subtitle">Slow Requests (last <%= RailsPerformance.slow_requests_time_window / 60 %> minutes + slower then <%= RailsPerformance.slow_requests_threshold %>ms)<h2>
8
+ </div>
9
+ </div>
10
+
11
+ <table id="recent" class="table is-fullwidth is-hoverable is-narrow">
12
+ <thead>
13
+ <tr>
14
+ <th data-sort="string"></th>
15
+ <th data-sort="string">Datetime</th>
16
+ <th data-sort="string">Controller#action</th>
17
+ <th data-sort="string">Method</th>
18
+ <th data-sort="string">Format</th>
19
+ <th data-sort="string">Path</th>
20
+ <th data-sort="string">Status</th>
21
+ <th data-sort="float">Duration</th>
22
+ <th data-sort="float">Views</th>
23
+ <th data-sort="float">DB</th>
24
+ <th></th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <% if @data.empty? %>
29
+ <tr>
30
+ <td colspan="10">Nothing to show here. Try to make a few requests in the main app.</td>
31
+ </tr>
32
+ <% end %>
33
+ <% @data.each do |e| %>
34
+ <%= render 'recent_row', e: e %>
35
+ <% end %>
36
+ </tbody>
37
+ </table>
38
+ </div>
39
+ </div>
@@ -18,6 +18,7 @@
18
18
  <%= link_to 'Requests Analysis', rails_performance.rails_performance_requests_url, class: "navbar-item #{active?(:requests)}" %>
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
+ <%= link_to 'Slow Requests', rails_performance.rails_performance_slow_url, class: "navbar-item #{active?(:slow)}" %>
21
22
  <% if defined?(Sidekiq) %>
22
23
  <%= link_to 'Sidekiq', rails_performance.rails_performance_sidekiq_url, class: "navbar-item #{active?(:sidekiq)}" %>
23
24
  <% end %>
data/config/routes.rb CHANGED
@@ -4,6 +4,7 @@ RailsPerformance::Engine.routes.draw do
4
4
  get '/requests' => 'rails_performance#requests', as: :rails_performance_requests
5
5
  get '/crashes' => 'rails_performance#crashes', as: :rails_performance_crashes
6
6
  get '/recent' => 'rails_performance#recent', as: :rails_performance_recent
7
+ get '/slow' => 'rails_performance#slow', as: :rails_performance_slow
7
8
 
8
9
  get '/trace/:id' => 'rails_performance#trace', as: :rails_performance_trace
9
10
  get '/summary' => 'rails_performance#summary', as: :rails_performance_summary
@@ -0,0 +1,24 @@
1
+ module RailsPerformance
2
+ module Reports
3
+ class SlowRequestsReport < BaseReport
4
+ def set_defaults
5
+ @sort ||= :datetimei
6
+ end
7
+
8
+ def data
9
+ db.data
10
+ .collect{|e| e.record_hash}
11
+ .select{|e| e if e[sort] > RailsPerformance.slow_requests_time_window.ago.to_i}
12
+ .sort{|a, b| b[sort] <=> a[sort]}
13
+ .filter{|e| e[:duration] > RailsPerformance.slow_requests_threshold.to_i}
14
+ .first(limit)
15
+ end
16
+
17
+ private
18
+
19
+ def limit
20
+ RailsPerformance.slow_requests_limit ? RailsPerformance.slow_requests_limit.to_i : 100_000
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,4 +1,4 @@
1
1
  module RailsPerformance
2
- VERSION = '1.0.5.3'
2
+ VERSION = '1.1.0'
3
3
  SCHEMA = '1.0.1'
4
4
  end
@@ -19,6 +19,7 @@ require_relative "rails_performance/reports/crash_report.rb"
19
19
  require_relative "rails_performance/reports/response_time_report.rb"
20
20
  require_relative "rails_performance/reports/throughput_report.rb"
21
21
  require_relative "rails_performance/reports/recent_requests_report.rb"
22
+ require_relative "rails_performance/reports/slow_requests_report.rb"
22
23
  require_relative "rails_performance/reports/breakdown_report.rb"
23
24
  require_relative "rails_performance/reports/trace_report.rb"
24
25
  require_relative "rails_performance/extensions/trace.rb"
@@ -39,6 +40,15 @@ module RailsPerformance
39
40
  mattr_accessor :recent_requests_limit
40
41
  @@recent_requests_limit = nil
41
42
 
43
+ mattr_accessor :slow_requests_time_window
44
+ @@slow_requests_time_window = 4.hours
45
+
46
+ mattr_accessor :slow_requests_limit
47
+ @@recent_requests_limit = 500
48
+
49
+ mattr_accessor :slow_requests_threshold
50
+ @@slow_requests_threshold = 500
51
+
42
52
  mattr_accessor :debug
43
53
  @@debug = false
44
54
 
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.0.5.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-11 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -253,6 +253,7 @@ files:
253
253
  - app/views/rails_performance/rails_performance/recent.js.erb
254
254
  - app/views/rails_performance/rails_performance/requests.html.erb
255
255
  - app/views/rails_performance/rails_performance/sidekiq.html.erb
256
+ - app/views/rails_performance/rails_performance/slow.html.erb
256
257
  - app/views/rails_performance/rails_performance/summary.js.erb
257
258
  - app/views/rails_performance/rails_performance/trace.js.erb
258
259
  - app/views/rails_performance/shared/_header.html.erb
@@ -292,6 +293,7 @@ files:
292
293
  - lib/rails_performance/reports/recent_requests_report.rb
293
294
  - lib/rails_performance/reports/requests_report.rb
294
295
  - lib/rails_performance/reports/response_time_report.rb
296
+ - lib/rails_performance/reports/slow_requests_report.rb
295
297
  - lib/rails_performance/reports/throughput_report.rb
296
298
  - lib/rails_performance/reports/trace_report.rb
297
299
  - lib/rails_performance/thread/current_request.rb
@@ -316,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
318
  - !ruby/object:Gem::Version
317
319
  version: '0'
318
320
  requirements: []
319
- rubygems_version: 3.4.10
321
+ rubygems_version: 3.4.13
320
322
  signing_key:
321
323
  specification_version: 4
322
324
  summary: Simple Rails Performance tracker. Alternative to the NewRelic, Datadog or