rails_performance 1.2.0.alpha4 → 1.2.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: 71e33d8156df40c792e33f03eae39a06c12f1622aa2c8071291c4e81c803d3ac
4
- data.tar.gz: 288c78335fec92abede6d72f82b841fd128ff079baad62d3a1ea3900003c5171
3
+ metadata.gz: e9f2906db73d1a2227a6479131dded794f1b9bc734fe85883f91938ef28b4b7d
4
+ data.tar.gz: 04fbf2f661f9873878b36a10906eb2346883d9f44c236557bbbc423270506c66
5
5
  SHA512:
6
- metadata.gz: 2617feffb5ceeb2c644679a4de52ecc60797350c883776cfd706b4d7a3c4fca77c93e15ad7243f4fe18c2612728b241f9584a5a7135947b7e8f66dec6f05ae59
7
- data.tar.gz: 8bff9d4b572f7bb41de93850651c210e0e59d6e03395e78d10ca777ace00ad31fb85f40c1153fe60062d3ac1a4094b1e6c0e64bef3c44757b3b8f102a776afb6
6
+ metadata.gz: e3be04836a44e3c1eddc5b5f338667952128ee1d99b70bbb635bf252205f21e99a4c4d60157a3517927801de5342671d02f9648918074ecd60152fd7ec7c5222
7
+ data.tar.gz: ec663b71500e15c4c29bada3d11111629c3130281a0140a7a3e872068ac0eecc6e13cd50b0a867254a3ff03d472dfc6b29d0bb2cdea84ae212a48b04c3b8beaa
@@ -95,17 +95,13 @@ module RailsPerformance
95
95
  def bot_icon(user_agent)
96
96
  return nil if user_agent.blank?
97
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
98
  browser = Browser.new(user_agent)
102
-
103
- if browser.bot? || rand(2) == 1
99
+ if browser.bot?
104
100
  content_tag(:span, class: "user-agent-icon", title: browser.bot&.name) do
105
101
  icon("bot")
106
102
  end
107
103
  else
108
- content_tag(:span, class: "user-agent-icon") do
104
+ content_tag(:span, class: "user-agent-icon user-agent-icon-user", title: "Real User") do
109
105
  icon("user")
110
106
  end
111
107
  end
@@ -7,13 +7,13 @@
7
7
  <% end %>
8
8
  </td>
9
9
  <td><%= format_datetime e[:datetime] %></td>
10
- <td><%= bot_icon e["user_agent"] %></td>
11
10
  <td>
12
11
  <% controller_action_info = e[:controller] + '#' + e[:action]%>
13
12
  <%= 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 %>
14
13
  </td>
15
14
  <td><%= e[:method] %></td>
16
15
  <td><%= e[:format] %></td>
16
+ <td><%= bot_icon e["user_agent"] %></td>
17
17
  <td><%= link_to_path(e) %></td>
18
18
  <td><%= status_tag e[:status] %></td>
19
19
  <td class="nowrap"><%= ms e[:duration] %></td>
@@ -5,11 +5,12 @@
5
5
  <div id="response_time_report_chart_mini" class="chart_mini"></div>
6
6
 
7
7
  <h2 class="subtitle"><%= title %></h2>
8
- <table class="table is-fullwidth is-hoverable is-narrow is-size-7">
8
+ <table class="table is-fullwidth is-hoverable is-narrow is-size-9">
9
9
  <thead>
10
10
  <tr>
11
11
  <th data-sort="string">Datetime</th>
12
12
  <th data-sort="string">Method</th>
13
+ <th></th>
13
14
  <th data-sort="string">Path</th>
14
15
  <th data-sort="string">Format</th>
15
16
  <th data-sort="int">Status</th>
@@ -23,6 +24,7 @@
23
24
  <tr>
24
25
  <td><%= format_datetime e[:datetime] %></td>
25
26
  <td><%= e[:method] %></td>
27
+ <td><%= bot_icon e["user_agent"] %></td>
26
28
  <td><%= link_to_path(e) %></td>
27
29
  <td><%= e[:format] %></td>
28
30
  <td><%= status_tag e[:status] %></td>
@@ -32,4 +34,4 @@
32
34
  </tr>
33
35
  <% end %>
34
36
  </tbody>
35
- </table>
37
+ </table>
@@ -8,6 +8,7 @@
8
8
  <th data-sort="string">Controller#action</th>
9
9
  <th data-sort="string">Method</th>
10
10
  <th data-sort="string">Format</th>
11
+ <th></th>
11
12
  <th data-sort="string">Path</th>
12
13
  <th data-sort="string">Exception</th>
13
14
  <th data-sort="string">Backtrace</th>
@@ -30,6 +31,7 @@
30
31
  <td><%= link_to e[:controller] + '#' + e[:action], rails_performance.rails_performance_summary_path({controller_eq: e[:controller], action_eq: e[:action]}), remote: true %></td>
31
32
  <td><%= e[:method] %></td>
32
33
  <td><%= e[:format] %></td>
34
+ <td><%= bot_icon e["user_agent"] %></td>
33
35
  <td><%= link_to_path(e) %></td>
34
36
  <td><%= e[:exception] %></td>
35
37
  <td class="very-small-text">
@@ -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 %>
@@ -19,10 +19,10 @@
19
19
  <tr>
20
20
  <th data-sort="string"></th>
21
21
  <th data-sort="string">Datetime</th>
22
- <th></th>
23
22
  <th data-sort="string">Controller#action</th>
24
23
  <th data-sort="string">Method</th>
25
24
  <th data-sort="string">Format</th>
25
+ <th></th>
26
26
  <th data-sort="string">Path</th>
27
27
  <th data-sort="string">Status</th>
28
28
  <th data-sort="float">Duration</th>
@@ -13,10 +13,10 @@
13
13
  <tr>
14
14
  <th data-sort="string"></th>
15
15
  <th data-sort="string">Datetime</th>
16
- <th></th>
17
16
  <th data-sort="string">Controller#action</th>
18
17
  <th data-sort="string">Method</th>
19
18
  <th data-sort="string">Format</th>
19
+ <th></th>
20
20
  <th data-sort="string">Path</th>
21
21
  <th data-sort="string">Status</th>
22
22
  <th data-sort="float">Duration</th>
@@ -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
  }
@@ -101,3 +105,13 @@ table th[data-sort] {
101
105
  #autoupdate_label {
102
106
  cursor: pointer;
103
107
  }
108
+
109
+ .is-size-8, .is-size-8 * {
110
+ font-size: 10px !important;
111
+ line-height: 20px !important;
112
+ }
113
+
114
+ .is-size-9, .is-size-9 * {
115
+ font-size: 7px !important;
116
+ line-height: 20px !important;
117
+ }
@@ -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,32 @@ 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
+ # read current values
43
+ db.group_by(group).each do |(k, v)|
44
+ yield(all, k, v)
45
+ end
46
+
47
+ # add blank columns
48
+ while current <= stop
49
+ key = (current).strftime(RailsPerformance::FORMAT)
50
+ views = all[key].presence || 0
51
+ @data << [(current.to_i + offset) * 1000, views.round(2)]
52
+ current += 1.minute
53
+ end
54
+
55
+ # sort by time
56
+ @data.sort!
57
+ end
32
58
  end
33
59
  end
34
60
  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,10 @@ module RailsPerformance
6
6
  @group ||= :datetime
7
7
  end
8
8
 
9
- # RailsPerformance::Reports::ThroughputReport.new(db).data
10
- # Time.at(RailsPerformance::Reports::ThroughputReport.new(db).data.last[0] / 1000)
11
-
12
9
  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)|
10
+ calculate_data do |all, k, v|
24
11
  all[k] = v.count
25
12
  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
13
  end
37
14
 
38
15
  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'
3
3
  SCHEMA = '1.0.1'
4
4
  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.2.0.alpha4
4
+ version: 1.2.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-24 00:00:00.000000000 Z
11
+ date: 2023-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -330,9 +330,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
330
330
  version: '0'
331
331
  required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  requirements:
333
- - - ">"
333
+ - - ">="
334
334
  - !ruby/object:Gem::Version
335
- version: 1.3.1
335
+ version: '0'
336
336
  requirements: []
337
337
  rubygems_version: 3.4.13
338
338
  signing_key: