rails_performance 1.0.0.beta3 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/rails_performance/rails_performance/crashes.html.erb +6 -0
- data/app/views/rails_performance/stylesheets/style.css +4 -0
- data/lib/rails_performance.rb +2 -2
- data/lib/rails_performance/instrument/metrics_collector.rb +7 -1
- data/lib/rails_performance/models/request_record.rb +16 -3
- data/lib/rails_performance/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38819433ac1ee118a96caab4f7ca4a539b2d995357df0a4bc04333ae55d3beb7
|
4
|
+
data.tar.gz: 207a4b1e375df67b0af5b3f446fe59cb50e608da207510fa64ad28e1f8366039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efa206d30d71c4b5721bbc8fad0df581b56a7ad0642b99f0d91c9e1ff1e5ff394951f68ddcd0ba498d5f60f2de8714bd9163a5f7912abdb548bd0d1bb8b2fce5
|
7
|
+
data.tar.gz: 9f4810ef1db85454e2ffefee36f2cedb43dd1d9495ef7ce993ecf4da364234fe04b0d644db7be9270fc2011f66bad47c6ebcdf73ed561e0711a07f88941c36aa
|
@@ -9,6 +9,8 @@
|
|
9
9
|
<th data-sort="string">Method</th>
|
10
10
|
<th data-sort="string">Format</th>
|
11
11
|
<th data-sort="string">Path</th>
|
12
|
+
<th data-sort="string">Exception</th>
|
13
|
+
<th data-sort="string">Backtrace</th>
|
12
14
|
<th data-sort="string">Status</th>
|
13
15
|
<th data-sort="float">Duration</th>
|
14
16
|
<th data-sort="float">Views</th>
|
@@ -29,6 +31,10 @@
|
|
29
31
|
<td><%= e[:method] %></td>
|
30
32
|
<td><%= e[:format] %></td>
|
31
33
|
<td><%= link_to_path(e) %></td>
|
34
|
+
<td><%= e[:exception] %></td>
|
35
|
+
<td class="very-small-text">
|
36
|
+
<%= raw e[:backtrace]&.join("<br/>") %>
|
37
|
+
</td>
|
32
38
|
<td><%= status_tag e[:status] %></td>
|
33
39
|
<td class="nowrap"><%= ms e[:duration] %></td>
|
34
40
|
<td class="nowrap"><%= ms e[:view_runtime] %></td>
|
data/lib/rails_performance.rb
CHANGED
@@ -17,6 +17,8 @@ module RailsPerformance
|
|
17
17
|
|
18
18
|
def call(event_name, started, finished, event_id, payload)
|
19
19
|
return if RailsPerformance.skip
|
20
|
+
return if CurrentRequest.current.data
|
21
|
+
|
20
22
|
# TODO do we need this new?
|
21
23
|
event = ActiveSupport::Notifications::Event.new(event_name, started, finished, event_id, payload)
|
22
24
|
|
@@ -33,9 +35,13 @@ module RailsPerformance
|
|
33
35
|
path: event.payload[:path],
|
34
36
|
view_runtime: event.payload[:view_runtime],
|
35
37
|
db_runtime: event.payload[:db_runtime],
|
36
|
-
duration: event.duration
|
38
|
+
duration: event.duration,
|
39
|
+
exception: event.payload[:exception],
|
40
|
+
exception_object: event.payload[:exception_object]
|
37
41
|
}
|
38
42
|
|
43
|
+
# pass the record to Thread.current
|
44
|
+
# and saves later in middleware
|
39
45
|
CurrentRequest.current.data = record
|
40
46
|
end
|
41
47
|
end
|
@@ -3,6 +3,7 @@ module RailsPerformance
|
|
3
3
|
class RequestRecord < BaseRecord
|
4
4
|
attr_accessor :controller, :action, :format, :status, :datetime, :datetimei, :method, :path, :request_id, :json
|
5
5
|
attr_accessor :view_runtime, :db_runtime, :duration, :http_referer
|
6
|
+
attr_accessor :exception, :exception_object
|
6
7
|
|
7
8
|
def RequestRecord.find_by(request_id:)
|
8
9
|
keys, values = RailsPerformance::Utils.fetch_from_redis("performance|*|request_id|#{request_id}|*")
|
@@ -24,7 +25,7 @@ module RailsPerformance
|
|
24
25
|
# path|/|
|
25
26
|
# request_id|454545454545454545|
|
26
27
|
# END|1.0.0
|
27
|
-
# = {"view_runtime":
|
28
|
+
# = {"view_runtime":null,"db_runtime":0,"duration":27.329741000000002,"http_referer":null,"exception":"ZeroDivisionError divided by 0","backtrace":["/root/projects/rails_performance/test/dummy/app/controllers/account/site_controller.rb:17:in `/'","/root/projects/rails_performance/test/dummy/app/controllers/account/site_controller.rb:17:in `crash'","/usr/local/rvm/gems/ruby-2.6.3/gems/actionpack-6.1.3.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'"]}
|
28
29
|
# value = JSON
|
29
30
|
def RequestRecord.from_db(key, value)
|
30
31
|
items = key.split("|")
|
@@ -43,7 +44,7 @@ module RailsPerformance
|
|
43
44
|
)
|
44
45
|
end
|
45
46
|
|
46
|
-
def initialize(controller:, action:, format:, status:, datetime:, datetimei:, method:, path:, request_id:, view_runtime: nil, db_runtime: nil, duration: nil, http_referer: nil, json: '{}')
|
47
|
+
def initialize(controller:, action:, format:, status:, datetime:, datetimei:, method:, path:, request_id:, view_runtime: nil, db_runtime: nil, duration: nil, http_referer: nil, exception: nil, exception_object: nil, json: '{}')
|
47
48
|
@controller = controller
|
48
49
|
@action = action
|
49
50
|
@format = format
|
@@ -59,6 +60,9 @@ module RailsPerformance
|
|
59
60
|
@duration = duration
|
60
61
|
@http_referer = http_referer
|
61
62
|
|
63
|
+
@exception = Array.wrap(exception).compact.join(" ")
|
64
|
+
@exception_object = exception_object
|
65
|
+
|
62
66
|
@json = json
|
63
67
|
end
|
64
68
|
|
@@ -84,12 +88,21 @@ module RailsPerformance
|
|
84
88
|
duration: self.value['duration'],
|
85
89
|
db_runtime: self.value['db_runtime'],
|
86
90
|
view_runtime: self.value['view_runtime'],
|
91
|
+
exception: self.value['exception'],
|
92
|
+
backtrace: self.value['backtrace']
|
87
93
|
}
|
88
94
|
end
|
89
95
|
|
90
96
|
def save
|
91
|
-
value = { view_runtime: view_runtime, db_runtime: db_runtime, duration: duration, http_referer: http_referer }
|
92
97
|
key = "performance|controller|#{controller}|action|#{action}|format|#{format}|status|#{status}|datetime|#{datetime}|datetimei|#{datetimei}|method|#{method}|path|#{path}|request_id|#{request_id}|END|#{RailsPerformance::SCHEMA}"
|
98
|
+
value = {
|
99
|
+
view_runtime: view_runtime,
|
100
|
+
db_runtime: db_runtime,
|
101
|
+
duration: duration,
|
102
|
+
http_referer: http_referer,
|
103
|
+
}
|
104
|
+
value[:exception] = exception if exception.present?
|
105
|
+
value[:backtrace] = exception_object.backtrace.take(3) if exception_object
|
93
106
|
Utils.save_to_redis(key, value)
|
94
107
|
end
|
95
108
|
|
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.0.0.
|
4
|
+
version: 1.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
- !ruby/object:Gem::Version
|
271
271
|
version: 1.3.1
|
272
272
|
requirements: []
|
273
|
-
rubygems_version: 3.
|
273
|
+
rubygems_version: 3.0.3
|
274
274
|
signing_key:
|
275
275
|
specification_version: 4
|
276
276
|
summary: Simple Rails Performance tracker. Alternative to the NewRelic, Datadog or
|