rails_performance 1.4.3 → 1.5.0
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 +26 -0
- data/app/views/rails_performance/javascripts/app.js +3 -1
- data/app/views/rails_performance/layouts/rails_performance.html.erb +3 -0
- data/lib/rails_performance/data_source.rb +1 -1
- data/lib/rails_performance/events/record.rb +62 -0
- data/lib/rails_performance/gems/custom_ext.rb +1 -0
- data/lib/rails_performance/gems/delayed_job_ext.rb +1 -0
- data/lib/rails_performance/gems/grape_ext.rb +1 -0
- data/lib/rails_performance/gems/rake_ext.rb +1 -0
- data/lib/rails_performance/gems/sidekiq_ext.rb +1 -0
- data/lib/rails_performance/interface.rb +7 -0
- data/lib/rails_performance/reports/annotations_report.rb +13 -0
- data/lib/rails_performance/reports/base_report.rb +2 -2
- data/lib/rails_performance/system_monitor/resources_monitor.rb +1 -1
- data/lib/rails_performance/utils.rb +6 -0
- data/lib/rails_performance/version.rb +2 -1
- data/lib/rails_performance.rb +5 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10d13bdf7ddb45da1783c3665a64a89730639a3b13061c496e4502a59158c329
|
4
|
+
data.tar.gz: 738313bc41c6af0d1cfee519679519639acda8781dd4dd74602e3c55a6b1f6de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33dcfe7183c335961e7716acc301b7c38877c9409c911ff0b6dfa0f5046ed40fc3f36fd9994cb8053367e467cb8c427eb042c218731cf7ada935fc6857c70b8d
|
7
|
+
data.tar.gz: e5e07d09bac167200fda9ff4e5b8d1bcd2e9558e4bc4a7bc9bf9c78d15f76d829f049c83793e7ef89c057bd83eda2ee2613ef6a01265a92aa6834dd891721047
|
data/README.md
CHANGED
@@ -34,6 +34,7 @@ It allows you to track:
|
|
34
34
|
- total duration of time spent per request, views rendering, DB
|
35
35
|
- SQL queries, rendering logs in "Recent Requests" section
|
36
36
|
- simple 500-crashes reports
|
37
|
+
- deployment events (or custom events)
|
37
38
|
- Sidekiq jobs
|
38
39
|
- Delayed Job jobs
|
39
40
|
- Grape API inside Rails app
|
@@ -237,6 +238,31 @@ More information here: `lib/rails_performance/engine.rb`.
|
|
237
238
|
|
238
239
|
PS: right now it can only distinguish between web app servers and the sidekiq servers.
|
239
240
|
|
241
|
+
#### Deployment Events + Custom Events on the Charts
|
242
|
+
|
243
|
+

|
244
|
+
|
245
|
+
#### For Kamal
|
246
|
+
|
247
|
+
- edit `.kamal/hooks/post-deploy` (rename .sample if needed)
|
248
|
+
- add `kamal app exec -p './bin/rails runner "RailsPerformance.create_event(name: \"Deploy\")"'`
|
249
|
+
- kamal deploy
|
250
|
+
|
251
|
+
#### Custom Events on the Charts
|
252
|
+
|
253
|
+
You can specify colors, orientation for the event label.
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
RailsPerformance.create_event(name: "Deploy", options: {
|
257
|
+
borderColor: "#00E396",
|
258
|
+
label: {
|
259
|
+
borderColor: "#00E396",
|
260
|
+
orientation: "horizontal",
|
261
|
+
text: "Deploy"
|
262
|
+
}
|
263
|
+
})
|
264
|
+
```
|
265
|
+
|
240
266
|
### Custom events
|
241
267
|
|
242
268
|
```ruby
|
@@ -79,7 +79,8 @@ function showTIRChart(element_id, data, addon, name) {
|
|
79
79
|
series: [{
|
80
80
|
name: name,
|
81
81
|
data: data
|
82
|
-
}]
|
82
|
+
}],
|
83
|
+
annotations: window?.annotationsData || {}
|
83
84
|
});
|
84
85
|
}
|
85
86
|
|
@@ -90,6 +91,7 @@ function showRTChart(element_id, data) {
|
|
90
91
|
name: 'Response Time',
|
91
92
|
data: data,
|
92
93
|
}],
|
94
|
+
annotations: window?.annotationsData || {}
|
93
95
|
});
|
94
96
|
}
|
95
97
|
|
@@ -8,6 +8,9 @@
|
|
8
8
|
<%= csp_meta_tag if ::Rails::VERSION::STRING.to_f >= 5.2 %>
|
9
9
|
<%= render '/rails_performance/stylesheets/stylesheets' %>
|
10
10
|
<link rel="shortcut icon" href="/favicon.ico">
|
11
|
+
<script>
|
12
|
+
window.annotationsData = <%= raw RailsPerformance::Reports::AnnotationsReport.new.data.to_json %>;
|
13
|
+
</script>
|
11
14
|
</head>
|
12
15
|
|
13
16
|
<body class="has-sticky-footer">
|
@@ -22,7 +22,7 @@ module RailsPerformance
|
|
22
22
|
|
23
23
|
def db
|
24
24
|
result = RailsPerformance::Models::Collection.new
|
25
|
-
now = RailsPerformance::Utils.
|
25
|
+
now = RailsPerformance::Utils.kind_of_now
|
26
26
|
(0..days).to_a.reverse_each do |e|
|
27
27
|
RailsPerformance::DataSource.new(q: q.merge({on: (now - e.days).to_date}), type: type).add_to(result)
|
28
28
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module RailsPerformance
|
2
|
+
module Events
|
3
|
+
class Record
|
4
|
+
attr_reader :name, :datetimei, :options
|
5
|
+
|
6
|
+
DEFAULT_COLOR = "#FF00FF"
|
7
|
+
DEFAULT_LABEL_COLOR = "#FF00FF"
|
8
|
+
DEFAULT_LABEL_ORIENTATION = "horizontal"
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def create(name:, datetimei: Time.now.to_i, options: {})
|
12
|
+
instance = new(name: name, datetimei: datetimei, options: options)
|
13
|
+
instance.save
|
14
|
+
instance
|
15
|
+
end
|
16
|
+
|
17
|
+
def all
|
18
|
+
_, values = RailsPerformance::Utils.fetch_from_redis("rails_performance:records:events:*")
|
19
|
+
Array(values).map do |value|
|
20
|
+
json = JSON.parse(value)
|
21
|
+
new(name: json["name"], datetimei: json["datetimei"], options: Hash(json["options"]))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(name:, datetimei:, options: {})
|
27
|
+
@name = name
|
28
|
+
@datetimei = datetimei
|
29
|
+
@options = options
|
30
|
+
end
|
31
|
+
|
32
|
+
def save
|
33
|
+
RailsPerformance::Utils.save_to_redis(rails_performance_key, value)
|
34
|
+
end
|
35
|
+
|
36
|
+
def rails_performance_key
|
37
|
+
"rails_performance:records:events:#{datetimei}|#{RailsPerformance::EVENTS_SCHEMA}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def value
|
41
|
+
{
|
42
|
+
name: name,
|
43
|
+
datetime: RailsPerformance::Utils.from_datetimei(datetimei.to_i),
|
44
|
+
datetimei: datetimei,
|
45
|
+
options: options
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_annotation
|
50
|
+
{
|
51
|
+
x: datetimei * 1000,
|
52
|
+
borderColor: options.dig("borderColor") || DEFAULT_COLOR,
|
53
|
+
label: {
|
54
|
+
borderColor: options.dig("label", "borderColor") || DEFAULT_LABEL_COLOR,
|
55
|
+
orientation: options.dig("label", "orientation") || DEFAULT_LABEL_ORIENTATION,
|
56
|
+
text: options.dig("label", "text") || name
|
57
|
+
}
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -32,7 +32,7 @@ module RailsPerformance
|
|
32
32
|
|
33
33
|
# TODO: simplify this method, and combine with nullify_data
|
34
34
|
def calculate_data
|
35
|
-
now = RailsPerformance::Utils.
|
35
|
+
now = RailsPerformance::Utils.kind_of_now
|
36
36
|
now = now.change(sec: 0, usec: 0)
|
37
37
|
stop = now # Time.at(60 * (now.to_i / 60), in:)
|
38
38
|
offset = 0 # RailsPerformance::Reports::BaseReport.time_in_app_time_zone(now).utc_offset
|
@@ -66,7 +66,7 @@ module RailsPerformance
|
|
66
66
|
def nil_data(duration = RailsPerformance.duration)
|
67
67
|
@nil_data ||= begin
|
68
68
|
result = {}
|
69
|
-
now = RailsPerformance::Utils.
|
69
|
+
now = RailsPerformance::Utils.kind_of_now
|
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
|
@@ -60,7 +60,7 @@ module RailsPerformance
|
|
60
60
|
def store_data(data)
|
61
61
|
::Rails.logger.info("Server: #{server_id}, Context: #{context}, Role: #{role}, data: #{data}")
|
62
62
|
|
63
|
-
now = RailsPerformance::Utils.
|
63
|
+
now = RailsPerformance::Utils.kind_of_now
|
64
64
|
now = now.change(sec: 0, usec: 0)
|
65
65
|
RailsPerformance::Models::ResourceRecord.new(
|
66
66
|
server: server_id,
|
@@ -1,9 +1,15 @@
|
|
1
1
|
module RailsPerformance
|
2
2
|
class Utils
|
3
|
+
DEFAULT_TIME_OFFSET = 1.minute
|
4
|
+
|
3
5
|
def self.time
|
4
6
|
Time.now.utc
|
5
7
|
end
|
6
8
|
|
9
|
+
def self.kind_of_now
|
10
|
+
time + DEFAULT_TIME_OFFSET
|
11
|
+
end
|
12
|
+
|
7
13
|
def self.from_datetimei(datetimei)
|
8
14
|
Time.at(datetimei, in: "+00:00")
|
9
15
|
end
|
data/lib/rails_performance.rb
CHANGED
@@ -26,10 +26,15 @@ require_relative "rails_performance/reports/breakdown_report"
|
|
26
26
|
require_relative "rails_performance/reports/trace_report"
|
27
27
|
require_relative "rails_performance/reports/percentile_report"
|
28
28
|
require_relative "rails_performance/reports/resources_report"
|
29
|
+
require_relative "rails_performance/reports/annotations_report"
|
30
|
+
require_relative "rails_performance/events/record"
|
29
31
|
require_relative "rails_performance/extensions/trace"
|
30
32
|
require_relative "rails_performance/thread/current_request"
|
33
|
+
require_relative "rails_performance/interface"
|
31
34
|
|
32
35
|
module RailsPerformance
|
36
|
+
extend RailsPerformance::Interface
|
37
|
+
|
33
38
|
FORMAT = "%Y%m%dT%H%M"
|
34
39
|
|
35
40
|
mattr_accessor :redis
|
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.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
@@ -347,6 +347,7 @@ files:
|
|
347
347
|
- lib/rails_performance.rb
|
348
348
|
- lib/rails_performance/data_source.rb
|
349
349
|
- lib/rails_performance/engine.rb
|
350
|
+
- lib/rails_performance/events/record.rb
|
350
351
|
- lib/rails_performance/extensions/trace.rb
|
351
352
|
- lib/rails_performance/gems/custom_ext.rb
|
352
353
|
- lib/rails_performance/gems/delayed_job_ext.rb
|
@@ -354,6 +355,7 @@ files:
|
|
354
355
|
- lib/rails_performance/gems/rake_ext.rb
|
355
356
|
- lib/rails_performance/gems/sidekiq_ext.rb
|
356
357
|
- lib/rails_performance/instrument/metrics_collector.rb
|
358
|
+
- lib/rails_performance/interface.rb
|
357
359
|
- lib/rails_performance/models/base_record.rb
|
358
360
|
- lib/rails_performance/models/collection.rb
|
359
361
|
- lib/rails_performance/models/custom_record.rb
|
@@ -366,6 +368,7 @@ files:
|
|
366
368
|
- lib/rails_performance/models/trace_record.rb
|
367
369
|
- lib/rails_performance/rails/middleware.rb
|
368
370
|
- lib/rails_performance/rails/query_builder.rb
|
371
|
+
- lib/rails_performance/reports/annotations_report.rb
|
369
372
|
- lib/rails_performance/reports/base_report.rb
|
370
373
|
- lib/rails_performance/reports/breakdown_report.rb
|
371
374
|
- lib/rails_performance/reports/crash_report.rb
|