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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71e33d8156df40c792e33f03eae39a06c12f1622aa2c8071291c4e81c803d3ac
4
- data.tar.gz: 288c78335fec92abede6d72f82b841fd128ff079baad62d3a1ea3900003c5171
3
+ metadata.gz: 62aee36c96f068b8caf8a8f9ba1eb7b0c00f8c6493a8f609f0adaca7e0c11f9b
4
+ data.tar.gz: b61d9ade77df9d29364694937e28fa57a029b497dc327872dc435006d412a136
5
5
  SHA512:
6
- metadata.gz: 2617feffb5ceeb2c644679a4de52ecc60797350c883776cfd706b4d7a3c4fca77c93e15ad7243f4fe18c2612728b241f9584a5a7135947b7e8f66dec6f05ae59
7
- data.tar.gz: 8bff9d4b572f7bb41de93850651c210e0e59d6e03395e78d10ca777ace00ad31fb85f40c1153fe60062d3ac1a4094b1e6c0e64bef3c44757b3b8f102a776afb6
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? || rand(2) == 1
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
@@ -30,4 +30,4 @@
30
30
  var data2 = <%= raw @response_time_report_data.to_json %>;
31
31
  showRTChart('response_time_report_chart', data2);
32
32
  </script>
33
- <% end %>
33
+ <% end %>
@@ -61,6 +61,10 @@
61
61
  height: 12px;
62
62
  }
63
63
 
64
+ .user-agent-icon-user svg path {
65
+ fill: hsl(141, 53%, 53%) !important;
66
+ }
67
+
64
68
  .chart {
65
69
  height: 245px;
66
70
  }
@@ -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.now - e.days).to_date }), type: type).add_to(result)
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.now
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.now - now) * 1000,
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.now
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.now - now) * 1000,
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.now
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.now
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.now - now) * 1000,
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.now
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.now - now) * 1000
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.now
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.now - t).round(3)}ms"
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
@@ -27,7 +27,7 @@ module RailsPerformance
27
27
  end
28
28
 
29
29
  def trace(options = {})
30
- @tracings << options.merge(time: Time.now.to_i)
30
+ @tracings << options.merge(time: Time.current.to_i)
31
31
  end
32
32
 
33
33
  end
@@ -8,7 +8,7 @@ module RailsPerformance
8
8
 
9
9
  # write to current slot
10
10
  # time - date -minute
11
- def Utils.field_key(now = Time.now)
11
+ def Utils.field_key(now = Time.current)
12
12
  now.strftime("%H:%M")
13
13
  end
14
14
 
@@ -1,4 +1,4 @@
1
1
  module RailsPerformance
2
- VERSION = '1.2.0.alpha4'
2
+ VERSION = '1.2.0.alpha5'
3
3
  SCHEMA = '1.0.1'
4
4
  end
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.alpha4
4
+ version: 1.2.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk