rails_performance 1.2.0.alpha3 → 1.2.0.alpha5
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/app/assets/images/bot.svg +1 -0
- data/app/assets/images/user.svg +1 -0
- data/app/controllers/rails_performance/rails_performance_controller.rb +19 -0
- data/app/helpers/rails_performance/application_helper.rb +24 -2
- data/app/views/rails_performance/rails_performance/_recent_row.html.erb +1 -0
- data/app/views/rails_performance/rails_performance/index.html.erb +1 -1
- data/app/views/rails_performance/rails_performance/recent.html.erb +1 -0
- data/app/views/rails_performance/rails_performance/slow.html.erb +1 -0
- data/app/views/rails_performance/stylesheets/style.css +9 -0
- data/lib/rails_performance/data_source.rb +1 -1
- data/lib/rails_performance/gems/custom_ext.rb +2 -2
- data/lib/rails_performance/gems/delayed_job_ext.rb +2 -2
- data/lib/rails_performance/gems/grape_ext.rb +1 -1
- data/lib/rails_performance/gems/rake_ext.rb +2 -2
- data/lib/rails_performance/gems/sidekiq_ext.rb +2 -2
- data/lib/rails_performance/rails/middleware.rb +2 -2
- data/lib/rails_performance/reports/base_report.rb +36 -0
- data/lib/rails_performance/reports/response_time_report.rb +1 -22
- data/lib/rails_performance/reports/throughput_report.rb +6 -21
- data/lib/rails_performance/thread/current_request.rb +1 -1
- data/lib/rails_performance/utils.rb +1 -1
- data/lib/rails_performance/version.rb +1 -1
- data/lib/rails_performance.rb +1 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62aee36c96f068b8caf8a8f9ba1eb7b0c00f8c6493a8f609f0adaca7e0c11f9b
|
4
|
+
data.tar.gz: b61d9ade77df9d29364694937e28fa57a029b497dc327872dc435006d412a136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb30056a19056d5b18c6f59af939e22bb4dda67adc0afb08d71ff4b215f4abac53bdd916e359e3655fa2e264be89d1b54af4dd8780bbfd1076e1b9d426c8d50a
|
7
|
+
data.tar.gz: f4806fa7db15d691a9ecc95597b7d262ad28a739840ccfe949bf8815a1ac83dfa411a26cc13bb7343009b878f30a250ae9a43fc004b04253e3cb437f6f40aac1
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" ?><svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M21.928 11.607c-.202-.488-.635-.605-.928-.633V8c0-1.103-.897-2-2-2h-6V4.61c.305-.274.5-.668.5-1.11a1.5 1.5 0 0 0-3 0c0 .442.195.836.5 1.11V6H5c-1.103 0-2 .897-2 2v2.997l-.082.006A1 1 0 0 0 1.99 12v2a1 1 0 0 0 1 1H3v5c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-5a1 1 0 0 0 1-1v-1.938a1.006 1.006 0 0 0-.072-.455zM5 20V8h14l.001 3.996L19 12v2l.001.005.001 5.995H5z"/><ellipse cx="8.5" cy="12" rx="1.5" ry="2"/><ellipse cx="15.5" cy="12" rx="1.5" ry="2"/><path d="M8 16h8v2H8z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" ?><svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2A10.13 10.13 0 0 0 2 12a10 10 0 0 0 4 7.92V20h.1a9.7 9.7 0 0 0 11.8 0h.1v-.08A10 10 0 0 0 22 12 10.13 10.13 0 0 0 12 2zM8.07 18.93A3 3 0 0 1 11 16.57h2a3 3 0 0 1 2.93 2.36 7.75 7.75 0 0 1-7.86 0zm9.54-1.29A5 5 0 0 0 13 14.57h-2a5 5 0 0 0-4.61 3.07A8 8 0 0 1 4 12a8.1 8.1 0 0 1 8-8 8.1 8.1 0 0 1 8 8 8 8 0 0 1-2.39 5.64z"/><path d="M12 6a3.91 3.91 0 0 0-4 4 3.91 3.91 0 0 0 4 4 3.91 3.91 0 0 0 4-4 3.91 3.91 0 0 0-4-4zm0 6a1.91 1.91 0 0 1-2-2 1.91 1.91 0 0 1 2-2 1.91 1.91 0 0 1 2 2 1.91 1.91 0 0 1-2 2z"/></svg>
|
@@ -55,6 +55,25 @@ module RailsPerformance
|
|
55
55
|
db = @datasource.db
|
56
56
|
@data = RailsPerformance::Reports::RecentRequestsReport.new(db).data(params[:from_timei])
|
57
57
|
|
58
|
+
# example
|
59
|
+
# :controller=>"HomeController",
|
60
|
+
# :action=>"index",
|
61
|
+
# :format=>"html",
|
62
|
+
# :status=>"200",
|
63
|
+
# :method=>"GET",
|
64
|
+
# :path=>"/",
|
65
|
+
# :request_id=>"9c9bff5f792a5b3f77cb07fa325f8ddf",
|
66
|
+
# :datetime=>2023-06-24 21:22:46 +0300,
|
67
|
+
# :datetimei=>1687630966,
|
68
|
+
# :duration=>207.225830078125,
|
69
|
+
# :db_runtime=>2.055999994277954,
|
70
|
+
# :view_runtime=>67.8370000096038,
|
71
|
+
# :exception=>nil,
|
72
|
+
# :backtrace=>nil,
|
73
|
+
# :http_referer=>nil,
|
74
|
+
# "email"=>nil,
|
75
|
+
# "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"}]
|
76
|
+
|
58
77
|
respond_to do |page|
|
59
78
|
page.html
|
60
79
|
page.js
|
@@ -92,9 +92,31 @@ module RailsPerformance
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
def bot_icon(user_agent)
|
96
|
+
return nil if user_agent.blank?
|
97
|
+
|
98
|
+
# TODO: clean this up
|
99
|
+
# user_agent = "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
100
|
+
|
101
|
+
browser = Browser.new(user_agent)
|
102
|
+
|
103
|
+
if browser.bot?
|
104
|
+
content_tag(:span, class: "user-agent-icon", title: browser.bot&.name) do
|
105
|
+
icon("bot")
|
106
|
+
end
|
107
|
+
else
|
108
|
+
content_tag(:span, class: "user-agent-icon user-agent-icon-user") do
|
109
|
+
icon("user")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
95
114
|
def icon(name)
|
96
|
-
|
97
|
-
|
115
|
+
@icons ||= {}
|
116
|
+
@icons[name] ||= begin
|
117
|
+
# https://www.iconfinder.com/iconsets/vivid
|
118
|
+
raw File.read(File.expand_path(File.dirname(__FILE__) + "/../../assets/images/#{name}.svg"))
|
119
|
+
end
|
98
120
|
end
|
99
121
|
|
100
122
|
def insert_css_file(file)
|
@@ -7,6 +7,7 @@
|
|
7
7
|
<% end %>
|
8
8
|
</td>
|
9
9
|
<td><%= format_datetime e[:datetime] %></td>
|
10
|
+
<td><%= bot_icon e["user_agent"] %></td>
|
10
11
|
<td>
|
11
12
|
<% controller_action_info = e[:controller] + '#' + e[:action]%>
|
12
13
|
<%= link_to truncate(controller_action_info, length: 40), rails_performance.rails_performance_summary_path({controller_eq: e[:controller], action_eq: e[:action]}), remote: true, title: controller_action_info %>
|
@@ -21,7 +21,7 @@ module RailsPerformance
|
|
21
21
|
def db
|
22
22
|
result = RailsPerformance::Models::Collection.new
|
23
23
|
(0..(RailsPerformance::Utils.days + 1)).to_a.reverse.each do |e|
|
24
|
-
RailsPerformance::DataSource.new(q: self.q.merge({ on: (Time.
|
24
|
+
RailsPerformance::DataSource.new(q: self.q.merge({ on: (Time.current - e.days).to_date }), type: type).add_to(result)
|
25
25
|
end
|
26
26
|
result
|
27
27
|
end
|
@@ -7,7 +7,7 @@ module RailsPerformance
|
|
7
7
|
return yield unless RailsPerformance.enabled
|
8
8
|
|
9
9
|
begin
|
10
|
-
now = Time.
|
10
|
+
now = Time.current
|
11
11
|
status = 'success'
|
12
12
|
result = yield
|
13
13
|
result
|
@@ -19,7 +19,7 @@ module RailsPerformance
|
|
19
19
|
tag_name: tag_name,
|
20
20
|
namespace_name: namespace_name,
|
21
21
|
status: status,
|
22
|
-
duration: (Time.
|
22
|
+
duration: (Time.current - now) * 1000,
|
23
23
|
datetime: now.strftime(RailsPerformance::FORMAT),
|
24
24
|
datetimei: now.to_i,
|
25
25
|
).save
|
@@ -6,7 +6,7 @@ module RailsPerformance
|
|
6
6
|
callbacks do |lifecycle|
|
7
7
|
lifecycle.around(:invoke_job) do |job, *args, &block|
|
8
8
|
begin
|
9
|
-
now = Time.
|
9
|
+
now = Time.current
|
10
10
|
block.call(job, *args)
|
11
11
|
status = 'success'
|
12
12
|
rescue Exception => error
|
@@ -16,7 +16,7 @@ module RailsPerformance
|
|
16
16
|
meta_data = RailsPerformance::Gems::DelayedJobExt::Plugin.meta(job.payload_object)
|
17
17
|
record = RailsPerformance::Models::DelayedJobRecord.new(
|
18
18
|
jid: job.id,
|
19
|
-
duration: (Time.
|
19
|
+
duration: (Time.current - now) * 1000,
|
20
20
|
datetime: now.strftime(RailsPerformance::FORMAT),
|
21
21
|
datetimei: now.to_i,
|
22
22
|
source_type: meta_data[0],
|
@@ -7,7 +7,7 @@ module RailsPerformance
|
|
7
7
|
# TODO change to set
|
8
8
|
CurrentRequest.current.ignore.add(:performance)
|
9
9
|
|
10
|
-
now = Time.
|
10
|
+
now = Time.current
|
11
11
|
CurrentRequest.current.data ||= {}
|
12
12
|
CurrentRequest.current.record ||= RailsPerformance::Models::GrapeRecord.new(request_id: CurrentRequest.current.request_id)
|
13
13
|
CurrentRequest.current.record.datetimei ||= now.to_i
|
@@ -6,7 +6,7 @@ module RailsPerformance
|
|
6
6
|
::Rake::Task.class_eval do
|
7
7
|
def invoke_with_rails_performance(*args)
|
8
8
|
begin
|
9
|
-
now = Time.
|
9
|
+
now = Time.current
|
10
10
|
status = 'success'
|
11
11
|
invoke_without_new_rails_performance(*args)
|
12
12
|
rescue Exception => ex
|
@@ -18,7 +18,7 @@ module RailsPerformance
|
|
18
18
|
task: RailsPerformance::Gems::RakeExt.find_task_name(*args),
|
19
19
|
datetime: now.strftime(RailsPerformance::FORMAT),
|
20
20
|
datetimei: now.to_i,
|
21
|
-
duration: (Time.
|
21
|
+
duration: (Time.current - now) * 1000,
|
22
22
|
status: status,
|
23
23
|
).save
|
24
24
|
end
|
@@ -6,7 +6,7 @@ module RailsPerformance
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(worker, msg, queue)
|
9
|
-
now = Time.
|
9
|
+
now = Time.current
|
10
10
|
record = RailsPerformance::Models::SidekiqRecord.new(
|
11
11
|
enqueued_ati: msg['enqueued_at'].to_i,
|
12
12
|
datetimei: msg['created_at'].to_i,
|
@@ -26,7 +26,7 @@ module RailsPerformance
|
|
26
26
|
raise ex
|
27
27
|
ensure
|
28
28
|
# store in ms instead of seconds
|
29
|
-
record.duration = (Time.
|
29
|
+
record.duration = (Time.current - now) * 1000
|
30
30
|
record.save
|
31
31
|
result
|
32
32
|
end
|
@@ -41,7 +41,7 @@ module RailsPerformance
|
|
41
41
|
def call!(env)
|
42
42
|
@status, @headers, @response = @app.call(env)
|
43
43
|
|
44
|
-
#t = Time.
|
44
|
+
#t = Time.current
|
45
45
|
if !RailsPerformance.skip
|
46
46
|
if !CurrentRequest.current.ignore.include?(:performance) # grape is executed first, and than ignore regular future storage of "controller"-like request
|
47
47
|
if data = CurrentRequest.current.data
|
@@ -66,7 +66,7 @@ module RailsPerformance
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
-
#puts "==> store performance data: #{(Time.
|
69
|
+
#puts "==> store performance data: #{(Time.current - t).round(3)}ms"
|
70
70
|
|
71
71
|
[@status, @headers, @response]
|
72
72
|
end
|
@@ -29,6 +29,42 @@ module RailsPerformance
|
|
29
29
|
time
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
def calculate_data
|
34
|
+
now = Time.current
|
35
|
+
stop = Time.at(60 * ((now.to_i)/ 60))
|
36
|
+
offset = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(now).utc_offset
|
37
|
+
current = stop - RailsPerformance.duration
|
38
|
+
|
39
|
+
@data = []
|
40
|
+
all = {}
|
41
|
+
|
42
|
+
# puts "current: #{current}"
|
43
|
+
# puts "stop: #{stop}"
|
44
|
+
|
45
|
+
# read current values
|
46
|
+
db.group_by(group).each do |(k, v)|
|
47
|
+
yield(all, k, v)
|
48
|
+
end
|
49
|
+
|
50
|
+
# puts '----'
|
51
|
+
# puts all
|
52
|
+
# puts '----'
|
53
|
+
# puts "offset: #{offset}"
|
54
|
+
# puts '======='
|
55
|
+
|
56
|
+
# add blank columns
|
57
|
+
while current <= stop
|
58
|
+
key = (current).strftime(RailsPerformance::FORMAT)
|
59
|
+
views = all[key].presence || 0
|
60
|
+
# puts "#{key} -> #{views}"
|
61
|
+
@data << [(current.to_i + offset) * 1000, views.round(2)]
|
62
|
+
current += 1.minute
|
63
|
+
end
|
64
|
+
|
65
|
+
# sort by time
|
66
|
+
@data.sort!
|
67
|
+
end
|
32
68
|
end
|
33
69
|
end
|
34
70
|
end
|
@@ -6,32 +6,11 @@ module RailsPerformance
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def data
|
9
|
-
all
|
10
|
-
stop = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.at(60 * (Time.now.to_i / 60)))
|
11
|
-
offset = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.now).utc_offset
|
12
|
-
current = stop - RailsPerformance.duration
|
13
|
-
@data = []
|
14
|
-
|
15
|
-
# puts "current: #{current}"
|
16
|
-
# puts "stop: #{stop}"
|
17
|
-
|
18
|
-
# read current values
|
19
|
-
db.group_by(group).each do |(k, v)|
|
9
|
+
calculate_data do |all, k, v|
|
20
10
|
durations = v.collect{|e| e["duration"]}.compact
|
21
11
|
next if durations.empty?
|
22
12
|
all[k] = durations.sum.to_f / durations.count
|
23
13
|
end
|
24
|
-
|
25
|
-
# add blank columns
|
26
|
-
while current <= stop
|
27
|
-
views = all[current.strftime(RailsPerformance::FORMAT)] || 0
|
28
|
-
# time = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(current)
|
29
|
-
@data << [(current.to_i + offset) * 1000, views.round(2)]
|
30
|
-
current += 1.minute
|
31
|
-
end
|
32
|
-
|
33
|
-
# sort by time
|
34
|
-
@data.sort!
|
35
14
|
end
|
36
15
|
end
|
37
16
|
end
|
@@ -6,33 +6,18 @@ module RailsPerformance
|
|
6
6
|
@group ||= :datetime
|
7
7
|
end
|
8
8
|
|
9
|
+
# def prepare_query(query = {})
|
10
|
+
# RailsPerformance::Rails::QueryBuilder.compose_from({})
|
11
|
+
# end
|
12
|
+
# @datasource = RailsPerformance::DataSource.new(**prepare_query({}), type: :requests)
|
13
|
+
# db = @datasource.db
|
9
14
|
# RailsPerformance::Reports::ThroughputReport.new(db).data
|
10
15
|
# Time.at(RailsPerformance::Reports::ThroughputReport.new(db).data.last[0] / 1000)
|
11
16
|
|
12
17
|
def data
|
13
|
-
all
|
14
|
-
stop = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.at(60 * (Time.now.to_i / 60)))
|
15
|
-
offset = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.now).utc_offset
|
16
|
-
current = stop - RailsPerformance.duration
|
17
|
-
@data = []
|
18
|
-
|
19
|
-
# puts "current: #{current}"
|
20
|
-
# puts "stop: #{stop}"
|
21
|
-
|
22
|
-
# read current values
|
23
|
-
db.group_by(group).each do |(k, v)|
|
18
|
+
calculate_data do |all, k, v|
|
24
19
|
all[k] = v.count
|
25
20
|
end
|
26
|
-
|
27
|
-
# add blank columns
|
28
|
-
while current <= stop
|
29
|
-
views = all[current.strftime(RailsPerformance::FORMAT)] || 0
|
30
|
-
@data << [(current.to_i + offset) * 1000, views.round(2)]
|
31
|
-
current += 1.minute
|
32
|
-
end
|
33
|
-
|
34
|
-
# sort by time
|
35
|
-
@data.sort!
|
36
21
|
end
|
37
22
|
|
38
23
|
end
|
data/lib/rails_performance.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_performance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.alpha5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: browser
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: sqlite3
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +233,7 @@ files:
|
|
219
233
|
- Rakefile
|
220
234
|
- app/assets/config/rails_performance_manifest.js
|
221
235
|
- app/assets/images/activity.svg
|
236
|
+
- app/assets/images/bot.svg
|
222
237
|
- app/assets/images/close.svg
|
223
238
|
- app/assets/images/export.svg
|
224
239
|
- app/assets/images/git.svg
|
@@ -227,6 +242,7 @@ files:
|
|
227
242
|
- app/assets/images/import.svg
|
228
243
|
- app/assets/images/menu.svg
|
229
244
|
- app/assets/images/stat.svg
|
245
|
+
- app/assets/images/user.svg
|
230
246
|
- app/controllers/rails_performance/base_controller.rb
|
231
247
|
- app/controllers/rails_performance/rails_performance_controller.rb
|
232
248
|
- app/helpers/rails_performance/application_helper.rb
|