rails_performance 1.4.0.alpha4 → 1.4.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/README.md +12 -0
- data/app/controllers/rails_performance/rails_performance_controller.rb +1 -1
- data/lib/generators/rails_performance/install/templates/initializer.rb +4 -0
- data/lib/rails_performance/data_source.rb +4 -3
- data/lib/rails_performance/models/resource_record.rb +2 -1
- data/lib/rails_performance/reports/base_report.rb +4 -4
- data/lib/rails_performance/reports/resources_report.rb +10 -4
- data/lib/rails_performance/utils.rb +2 -2
- data/lib/rails_performance/version.rb +1 -1
- data/lib/rails_performance.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9541b647e5e0ae0e49c8ffe55befda74884e9a8c53c9557cffd4b8c42ca23fc
|
4
|
+
data.tar.gz: 8b1ada0884c84dbbab0306cffab9bbb4f4b04b0fc4107a55747eae5416ed26ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2db12562f40ce01aa3bffa6a545e4567469972ec5ab79a0e7318dbe526b09c62e6c2f6f2fecadecb44485e5ea6f3bb4a7a4d632d7938e9a347af86144ea19b9
|
7
|
+
data.tar.gz: 7e7bed31f33b4f0af24362ec621f7d066b33d3225103e08b2819bc33b9b69a1fbc1d5c4ba65221d1c47186b6ab9d954d403eddf6317c7b9a94dfd445ca8f9004
|
data/README.md
CHANGED
@@ -117,9 +117,21 @@ RailsPerformance.setup do |config|
|
|
117
117
|
|
118
118
|
# To monitor custom events with `RailsPerformance.measure` block
|
119
119
|
# config.include_custom_events = true
|
120
|
+
|
121
|
+
# To monitor system resources (CPU, memory, disk)
|
122
|
+
# to enabled add required gems (see README)
|
123
|
+
# config.system_monitor_duration = 24.hours
|
120
124
|
end if defined?(RailsPerformance)
|
121
125
|
```
|
122
126
|
|
127
|
+
Additionally you might need to configure app time zone. You can do it in `config/application.rb`:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
config.time_zone = 'Eastern Time (US & Canada)'
|
131
|
+
```
|
132
|
+
|
133
|
+
Gem will present charts/tables in the app timezone. If it's not set, it will use UTC.
|
134
|
+
|
123
135
|
## Installation
|
124
136
|
|
125
137
|
Add this line to your application's Gemfile:
|
@@ -15,7 +15,7 @@ module RailsPerformance
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def resources
|
18
|
-
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :resources)
|
18
|
+
@datasource = RailsPerformance::DataSource.new(**prepare_query(params), type: :resources, days: RailsPerformance::Utils.days(RailsPerformance.system_monitor_duration))
|
19
19
|
db = @datasource.db
|
20
20
|
|
21
21
|
@resources_report = RailsPerformance::Reports::ResourcesReport.new(db)
|
@@ -52,5 +52,9 @@ if defined?(RailsPerformance)
|
|
52
52
|
config.skipable_rake_tasks = ["webpacker:compile"]
|
53
53
|
config.include_rake_tasks = false
|
54
54
|
config.include_custom_events = true
|
55
|
+
|
56
|
+
# If enabled, the system monitor will be displayed on the dashboard
|
57
|
+
# to enabled add required gems (see README)
|
58
|
+
# config.system_monitor_duration = 24.hours
|
55
59
|
end
|
56
60
|
end
|
@@ -10,19 +10,20 @@ module RailsPerformance
|
|
10
10
|
resources: RailsPerformance::Models::ResourceRecord
|
11
11
|
}
|
12
12
|
|
13
|
-
attr_reader :q, :klass, :type
|
13
|
+
attr_reader :q, :klass, :type, :days
|
14
14
|
|
15
|
-
def initialize(type:, q: {})
|
15
|
+
def initialize(type:, q: {}, days: RailsPerformance::Utils.days(RailsPerformance.duration))
|
16
16
|
@type = type
|
17
17
|
@klass = KLASSES[type]
|
18
18
|
q[:on] ||= Date.today
|
19
19
|
@q = q
|
20
|
+
@days = days
|
20
21
|
end
|
21
22
|
|
22
23
|
def db
|
23
24
|
result = RailsPerformance::Models::Collection.new
|
24
25
|
now = RailsPerformance::Utils.time
|
25
|
-
(0..
|
26
|
+
(0..days).to_a.reverse_each do |e|
|
26
27
|
RailsPerformance::DataSource.new(q: q.merge({on: (now - e.days).to_date}), type: type).add_to(result)
|
27
28
|
end
|
28
29
|
result
|
@@ -40,7 +40,8 @@ module RailsPerformance
|
|
40
40
|
|
41
41
|
def save
|
42
42
|
key = "resource|server|#{server}|context|#{context}|role|#{role}|datetime|#{datetime}|datetimei|#{datetimei}|END|#{RailsPerformance::SCHEMA}"
|
43
|
-
|
43
|
+
# with longer expiration time
|
44
|
+
Utils.save_to_redis(key, json, RailsPerformance.system_monitor_duration.to_i)
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
@@ -63,14 +63,14 @@ module RailsPerformance
|
|
63
63
|
# 1732125550000 => 0,
|
64
64
|
# ....
|
65
65
|
# }
|
66
|
-
def nil_data
|
66
|
+
def nil_data(duration = RailsPerformance.duration)
|
67
67
|
@nil_data ||= begin
|
68
68
|
result = {}
|
69
69
|
now = RailsPerformance::Utils.time
|
70
70
|
now = now.change(sec: 0, usec: 0)
|
71
71
|
stop = now # Time.at(60 * (now.to_i / 60))
|
72
72
|
offset = 0 # RailsPerformance::Reports::BaseReport.time_in_app_time_zone(now).utc_offset
|
73
|
-
current = stop -
|
73
|
+
current = stop - duration
|
74
74
|
|
75
75
|
while current <= stop
|
76
76
|
current.strftime(RailsPerformance::FORMAT)
|
@@ -86,8 +86,8 @@ module RailsPerformance
|
|
86
86
|
# 1732125540000 => 1,
|
87
87
|
# 1732125550000 => 0,
|
88
88
|
# }
|
89
|
-
def nullify_data(input)
|
90
|
-
nil_data.merge(input).sort
|
89
|
+
def nullify_data(input, duration = RailsPerformance.duration)
|
90
|
+
nil_data(duration).merge(input).sort
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -5,13 +5,13 @@ module RailsPerformance
|
|
5
5
|
@data ||= db.data
|
6
6
|
.collect { |e| e.record_hash }
|
7
7
|
.group_by { |e| e[:server] + "///" + e[:context] + "///" + e[:role] }
|
8
|
-
.transform_values { |v| v.sort { |a, b| b[sort] <=> a[sort] } }
|
8
|
+
# .transform_values { |v| v.sort { |a, b| b[sort] <=> a[sort] } }
|
9
9
|
.transform_values { |v| v.map { |e| e.merge({datetimei: e[:datetimei].to_i}) } }
|
10
10
|
end
|
11
11
|
|
12
12
|
def cpu
|
13
13
|
@cpu ||= data.transform_values do |v|
|
14
|
-
|
14
|
+
prepare_report(v.each_with_object({}) do |e, res|
|
15
15
|
res[e[:datetimei] * 1000] = e[:cpu]["one_min"].to_f.round(2)
|
16
16
|
end)
|
17
17
|
end
|
@@ -19,7 +19,7 @@ module RailsPerformance
|
|
19
19
|
|
20
20
|
def memory
|
21
21
|
@memory ||= data.transform_values do |v|
|
22
|
-
|
22
|
+
prepare_report(v.each_with_object({}) do |e, res|
|
23
23
|
res[e[:datetimei] * 1000] = e[:memory].to_f.round(2)
|
24
24
|
end)
|
25
25
|
end
|
@@ -27,11 +27,17 @@ module RailsPerformance
|
|
27
27
|
|
28
28
|
def disk
|
29
29
|
@disk ||= data.transform_values do |v|
|
30
|
-
|
30
|
+
prepare_report(v.each_with_object({}) do |e, res|
|
31
31
|
res[e[:datetimei] * 1000] = e[:disk]["available"].to_f.round(2)
|
32
32
|
end)
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def prepare_report(input)
|
39
|
+
nullify_data(input, RailsPerformance.system_monitor_duration)
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
@@ -40,8 +40,8 @@ module RailsPerformance
|
|
40
40
|
RailsPerformance.redis.set(key, value.to_json, ex: expire.to_i)
|
41
41
|
end
|
42
42
|
|
43
|
-
def self.days
|
44
|
-
(
|
43
|
+
def self.days(duration = RailsPerformance.duration)
|
44
|
+
(duration / 1.day) + 1
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.median(array)
|
data/lib/rails_performance.rb
CHANGED
@@ -119,6 +119,14 @@ module RailsPerformance
|
|
119
119
|
mattr_accessor :ignore_trace_headers
|
120
120
|
@@ignore_trace_headers = ["datetimei"]
|
121
121
|
|
122
|
+
# System monitor duration (expiration time)
|
123
|
+
mattr_accessor :system_monitor_duration
|
124
|
+
@@system_monitor_duration = 24.hours
|
125
|
+
|
126
|
+
# -- internal usage --
|
127
|
+
#
|
128
|
+
#
|
129
|
+
# to store the resource monitor instance
|
122
130
|
mattr_accessor :_resource_monitor
|
123
131
|
@@_resource_monitor = nil
|
124
132
|
|
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.4.0.
|
4
|
+
version: 1.4.0.alpha5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|