rails_performance 1.2.0.alpha4 → 1.2.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/rails_performance/application_helper.rb +2 -2
- data/app/views/rails_performance/rails_performance/index.html.erb +1 -1
- data/app/views/rails_performance/stylesheets/style.css +4 -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
- metadata +1 -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
|
@@ -100,12 +100,12 @@ module RailsPerformance
|
|
100
100
|
|
101
101
|
browser = Browser.new(user_agent)
|
102
102
|
|
103
|
-
if browser.bot?
|
103
|
+
if browser.bot?
|
104
104
|
content_tag(:span, class: "user-agent-icon", title: browser.bot&.name) do
|
105
105
|
icon("bot")
|
106
106
|
end
|
107
107
|
else
|
108
|
-
content_tag(:span, class: "user-agent-icon") do
|
108
|
+
content_tag(:span, class: "user-agent-icon user-agent-icon-user") do
|
109
109
|
icon("user")
|
110
110
|
end
|
111
111
|
end
|
@@ -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
|