rorvswild 1.5.9 → 1.5.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -0
- data/lib/rorvswild/agent.rb +18 -4
- data/lib/rorvswild/local/{local.html → local.html.erb} +1 -1
- data/lib/rorvswild/local/middleware.rb +7 -1
- data/lib/rorvswild/local/stylesheet/local.css +24 -0
- data/lib/rorvswild/local.rb +2 -2
- data/lib/rorvswild/locator.rb +6 -2
- data/lib/rorvswild/plugin/action_controller.rb +1 -1
- data/lib/rorvswild/queue.rb +1 -1
- data/lib/rorvswild/rails_loader.rb +9 -10
- data/lib/rorvswild/version.rb +1 -1
- data/lib/rorvswild.rb +4 -0
- 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: 262b40730d9fc77d334a2f3b4da10d4ddaea1cbd06b5c6c7da320d214ce18715
|
4
|
+
data.tar.gz: abe5d9f0bcda336c7ced3a1eee9071c3d9fdef32c9c49c45914fb483d093ed2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b809c27a4e650398c384ee828026381828d145393ea13f31d02cedc9b17be540dd0bec22845b293526d33658b33e5118faddaebf21866016c902f233e30a722
|
7
|
+
data.tar.gz: 9c75b3789da4f450ee58bd47b9bdbb536b6076a28af82366b2c18f4546e5e2d04cbe8df5c4db1362731b83719e1713a2525bc03b25cb5108eab56827056717a5
|
data/README.md
CHANGED
@@ -47,6 +47,8 @@ RorVsWild.start(api_key: API_KEY)
|
|
47
47
|
|
48
48
|
You can create unlimited apps on *rorvswild.com*. If you want to monitor your staging environment, create a new app and edit your rorvswild.yml to add the API key.
|
49
49
|
|
50
|
+
In case there is no data in the dashboard, you can run in a rails console : `RorVsWild.check`.
|
51
|
+
|
50
52
|
## Development mode: *RoRvsWild Local*
|
51
53
|
|
52
54
|
![RoRvsWild Local](./images/rorvswild_local.jpg)
|
@@ -56,6 +58,19 @@ It shows most of the requests performances insights *RoRvsWild.com* displays. **
|
|
56
58
|
|
57
59
|
*RoRvsWild Local* renders a small button in the bottom left corner of your page showing the runtime of the current request. If you click on it, you get all the profiled sections ordered by impact, which is depending on the sections average runtime and the calls count. As on RoRvsWild.com, the bottleneck is always on the top of the list.
|
58
60
|
|
61
|
+
You may want to hide or change the widget position like in the example below with the `widget` option :
|
62
|
+
|
63
|
+
```yaml
|
64
|
+
# config/rorvswild.yml
|
65
|
+
|
66
|
+
development:
|
67
|
+
widget: top-right
|
68
|
+
|
69
|
+
#accepted values : top-left, top-right, bottom-right, bottom-left (default), hidden
|
70
|
+
```
|
71
|
+
|
72
|
+
You can still access the profiler at http://localhost:3000/rorvswild if you choose to hide the widget.
|
73
|
+
|
59
74
|
Be aware that the performances on your development machine may vary from the production server. Obviously because of the different hardware and database size. Also, Rails is reloading all the code in development environment and this takes quite a lot of time.
|
60
75
|
To prevent this behaviour and better match the production, turn on cache_classes in your config/environments/development.rb:
|
61
76
|
|
@@ -121,6 +136,18 @@ RorVsWild.record_error(exception, {something: "important"})
|
|
121
136
|
RorVsWild.catch_error(something: "important") { 1 / 0 }
|
122
137
|
```
|
123
138
|
|
139
|
+
It is also possible to pre-fill this context data at the begining of each request or job :
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
class ApplicationController < ActionController::Base
|
143
|
+
before_action :prefill_error_context
|
144
|
+
|
145
|
+
def prefill_error_context
|
146
|
+
RorVsWild.merge_error_context(something: "important")
|
147
|
+
end
|
148
|
+
end
|
149
|
+
```
|
150
|
+
|
124
151
|
#### Ignore requests, jobs, exceptions and plugins
|
125
152
|
|
126
153
|
From the configuration file, you can tell RorVsWild to skip monitoring some requests, jobs, exceptions and plugins.
|
data/lib/rorvswild/agent.rb
CHANGED
@@ -30,7 +30,7 @@ module RorVsWild
|
|
30
30
|
@queue = config[:queue] || Queue.new(client)
|
31
31
|
@locator = RorVsWild::Locator.new
|
32
32
|
|
33
|
-
RorVsWild.logger.
|
33
|
+
RorVsWild.logger.debug("Start RorVsWild #{RorVsWild::VERSION}")
|
34
34
|
setup_plugins
|
35
35
|
cleanup_data
|
36
36
|
end
|
@@ -39,7 +39,7 @@ module RorVsWild
|
|
39
39
|
for name in RorVsWild::Plugin.constants
|
40
40
|
next if config[:ignore_plugins] && config[:ignore_plugins].include?(name.to_s)
|
41
41
|
if (plugin = RorVsWild::Plugin.const_get(name)).respond_to?(:setup)
|
42
|
-
RorVsWild.logger.
|
42
|
+
RorVsWild.logger.debug("Setup RorVsWild::Plugin::#{name}")
|
43
43
|
plugin.setup
|
44
44
|
end
|
45
45
|
end
|
@@ -107,11 +107,24 @@ module RorVsWild
|
|
107
107
|
|
108
108
|
def push_exception(exception, options = nil)
|
109
109
|
return if ignored_exception?(exception)
|
110
|
+
return unless current_data
|
110
111
|
current_data[:error] = exception_to_hash(exception)
|
111
112
|
current_data[:error].merge!(options) if options
|
112
113
|
current_data[:error]
|
113
114
|
end
|
114
115
|
|
116
|
+
def merge_error_context(hash)
|
117
|
+
self.error_context = error_context ? error_context.merge(hash) : hash
|
118
|
+
end
|
119
|
+
|
120
|
+
def error_context
|
121
|
+
current_data[:error_context] if current_data
|
122
|
+
end
|
123
|
+
|
124
|
+
def error_context=(hash)
|
125
|
+
current_data[:error_context] = hash if current_data
|
126
|
+
end
|
127
|
+
|
115
128
|
def current_data
|
116
129
|
Thread.current[:rorvswild_data]
|
117
130
|
end
|
@@ -161,15 +174,16 @@ module RorVsWild
|
|
161
174
|
client.post_async("/errors".freeze, error: hash)
|
162
175
|
end
|
163
176
|
|
164
|
-
def exception_to_hash(exception,
|
177
|
+
def exception_to_hash(exception, context = nil)
|
165
178
|
file, line = locator.find_most_relevant_file_and_line_from_exception(exception)
|
179
|
+
context = context ? error_context.merge(context) : error_context if error_context
|
166
180
|
{
|
167
181
|
line: line.to_i,
|
168
182
|
file: locator.relative_path(file),
|
169
183
|
message: exception.message,
|
170
184
|
backtrace: exception.backtrace || ["No backtrace"],
|
171
185
|
exception: exception.class.to_s,
|
172
|
-
extra_details:
|
186
|
+
extra_details: context,
|
173
187
|
environment: {
|
174
188
|
os: os_description,
|
175
189
|
user: Etc.getlogin,
|
@@ -56,9 +56,15 @@ module RorVsWild
|
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
+
def widget_css
|
60
|
+
config = RorVsWild.agent.config
|
61
|
+
config && config[:widget] && "is-#{config[:widget]}"
|
62
|
+
end
|
63
|
+
|
59
64
|
def inject_into(html)
|
60
65
|
if index = html.index("</body>")
|
61
|
-
markup = File.read(File.join(LOCAL_FOLDER, "local.html"))
|
66
|
+
markup = File.read(File.join(LOCAL_FOLDER, "local.html.erb"))
|
67
|
+
markup = ERB.new(markup).result(binding)
|
62
68
|
markup = markup.html_safe if markup.respond_to?(:html_safe)
|
63
69
|
html.insert(index, markup)
|
64
70
|
end
|
@@ -25,6 +25,30 @@
|
|
25
25
|
display: inline-block !important;
|
26
26
|
}
|
27
27
|
|
28
|
+
/************* TOGGLER POSITION OPTION(default bottom-left)**********************/
|
29
|
+
|
30
|
+
.is-top-right .rorvswild-local-toggler {
|
31
|
+
bottom: auto !important;
|
32
|
+
left: auto !important;
|
33
|
+
right: 12px !important;
|
34
|
+
top: 12px !important;
|
35
|
+
}
|
36
|
+
|
37
|
+
.is-top-left .rorvswild-local-toggler {
|
38
|
+
bottom: auto !important;
|
39
|
+
top: 12px !important;
|
40
|
+
}
|
41
|
+
|
42
|
+
.is-bottom-right .rorvswild-local-toggler {
|
43
|
+
bottom: 12px !important;
|
44
|
+
left: auto !important;
|
45
|
+
right: 12px !important;
|
46
|
+
}
|
47
|
+
|
48
|
+
.is-hidden .rorvswild-local-toggler {
|
49
|
+
display: none;
|
50
|
+
}
|
51
|
+
|
28
52
|
/********************************************/
|
29
53
|
/*************** PANEL **********************/
|
30
54
|
/********************************************/
|
data/lib/rorvswild/local.rb
CHANGED
@@ -3,9 +3,9 @@ require "rorvswild/local/queue"
|
|
3
3
|
|
4
4
|
module RorVsWild
|
5
5
|
module Local
|
6
|
-
def self.start
|
6
|
+
def self.start(config = {})
|
7
7
|
Rails.application.config.middleware.unshift(RorVsWild::Local::Middleware, nil)
|
8
|
-
RorVsWild.start(queue: RorVsWild::Local::Queue.new)
|
8
|
+
RorVsWild.start(config.merge(queue: RorVsWild::Local::Queue.new))
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/rorvswild/locator.rb
CHANGED
@@ -12,7 +12,7 @@ module RorVsWild
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def find_most_relevant_location(locations)
|
15
|
-
locations.find { |l| relevant_path?(l.path) } || locations.find { |l| !
|
15
|
+
locations.find { |l| relevant_path?(l.path) } || locations.find { |l| !l.path.start_with?(rorvswild_lib_path) } || locations.first
|
16
16
|
end
|
17
17
|
|
18
18
|
def find_most_relevant_file_and_line_from_exception(exception)
|
@@ -29,7 +29,7 @@ module RorVsWild
|
|
29
29
|
|
30
30
|
def find_most_relevant_file_and_line_from_array_of_strings(stack)
|
31
31
|
location = stack.find { |str| relevant_path?(str) }
|
32
|
-
location ||= stack.find { |str| !
|
32
|
+
location ||= stack.find { |str| !str.start_with?(rorvswild_lib_path) }
|
33
33
|
relative_path(location || stack.first).split(":".freeze)
|
34
34
|
end
|
35
35
|
|
@@ -49,6 +49,10 @@ module RorVsWild
|
|
49
49
|
@lib_paths ||= initialize_lib_paths
|
50
50
|
end
|
51
51
|
|
52
|
+
def rorvswild_lib_path
|
53
|
+
@rorvswild_lib_path ||= File.dirname(File.expand_path(__FILE__))
|
54
|
+
end
|
55
|
+
|
52
56
|
private
|
53
57
|
|
54
58
|
def initialize_lib_paths
|
@@ -23,7 +23,7 @@ module RorVsWild
|
|
23
23
|
section.file, section.line = controller.method(method_name).source_location
|
24
24
|
section.file = RorVsWild.agent.locator.relative_path(section.file)
|
25
25
|
section.command = "#{controller.class}##{method_name}"
|
26
|
-
RorVsWild.agent.current_data[:name] = controller_action
|
26
|
+
RorVsWild.agent.current_data[:name] = controller_action if RorVsWild.agent.current_data
|
27
27
|
end
|
28
28
|
block.call
|
29
29
|
ensure
|
data/lib/rorvswild/queue.rb
CHANGED
@@ -10,20 +10,19 @@ module RorVsWild
|
|
10
10
|
def self.start
|
11
11
|
return if RorVsWild.agent
|
12
12
|
|
13
|
-
if (
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
if !RorVsWild.agent && Rails.env.development?
|
13
|
+
if (config = load_config) && config[:api_key]
|
14
|
+
RorVsWild.start(config)
|
15
|
+
elsif Rails.env.development?
|
20
16
|
require "rorvswild/local"
|
21
|
-
RorVsWild::Local.start
|
17
|
+
RorVsWild::Local.start(config || {})
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
25
|
-
def self.
|
26
|
-
|
21
|
+
def self.load_config
|
22
|
+
if (path = Rails.root.join("config/rorvswild.yml")).exist?
|
23
|
+
hash = YAML.load(ERB.new(path.read).result)[Rails.env]
|
24
|
+
hash && hash.deep_symbolize_keys
|
25
|
+
end
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
data/lib/rorvswild/version.rb
CHANGED
data/lib/rorvswild.rb
CHANGED
@@ -39,6 +39,10 @@ module RorVsWild
|
|
39
39
|
agent.record_error(exception, extra_details) if agent
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.merge_error_context(hash)
|
43
|
+
agent.merge_error_context(hash) if agent
|
44
|
+
end
|
45
|
+
|
42
46
|
def self.initialize_logger(destination = nil)
|
43
47
|
if destination.respond_to?(:info) && destination.respond_to?(:warn) && destination.respond_to?(:error)
|
44
48
|
destination
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Performances and errors insights for rails developers.
|
15
15
|
email:
|
@@ -34,7 +34,7 @@ files:
|
|
34
34
|
- lib/rorvswild/local/javascript/vendor/barber.js
|
35
35
|
- lib/rorvswild/local/javascript/vendor/mustache.js
|
36
36
|
- lib/rorvswild/local/javascript/vendor/prism.js
|
37
|
-
- lib/rorvswild/local/local.html
|
37
|
+
- lib/rorvswild/local/local.html.erb
|
38
38
|
- lib/rorvswild/local/middleware.rb
|
39
39
|
- lib/rorvswild/local/queue.rb
|
40
40
|
- lib/rorvswild/local/stylesheet/local.css
|