rorvswild 1.5.11 → 1.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -17
- data/lib/rorvswild/agent.rb +17 -4
- data/lib/rorvswild/plugin/net_http.rb +1 -4
- data/lib/rorvswild/plugin/redis.rb +1 -1
- data/lib/rorvswild/rails_loader.rb +1 -1
- data/lib/rorvswild/version.rb +1 -1
- data/lib/rorvswild.rb +8 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46b5f40b58c450a91d4ccef20ecca01087c6a91ab5914fc15dacf98f759ba2ef
|
4
|
+
data.tar.gz: '094aaa9bccc0c1ba609407de5f253875ef86a537392cc740d5daea3b35b6b294'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3f133b046fe451a3f2614a56db5b4581e74f1679ee1a5678f4e03ad070c1e57c14ae344d59126efe217aedaac9f27b9e09c19501bb5c1a64c395e5199352c74
|
7
|
+
data.tar.gz: ebf70177f6200fd0f2103e4cd2f2a3fe8378a6a02871c5d66de5299c2228c4906d17c23fc3185b6b0a3f7385abc3b28dd248f6554864ec93bbb21911a5499624
|
data/README.md
CHANGED
@@ -58,19 +58,18 @@ It shows most of the requests performances insights *RoRvsWild.com* displays. **
|
|
58
58
|
|
59
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.
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
You may want to hide or change the widget position like in the example below with the `widget` option :
|
63
62
|
|
64
63
|
```yaml
|
65
64
|
# config/rorvswild.yml
|
66
65
|
|
67
66
|
development:
|
68
|
-
widget: top-right
|
69
|
-
|
70
|
-
|
67
|
+
widget: top-right
|
68
|
+
|
69
|
+
#accepted values : top-left, top-right, bottom-right, bottom-left (default), hidden
|
71
70
|
```
|
72
71
|
|
73
|
-
|
72
|
+
You can still access the profiler at http://localhost:3000/rorvswild if you choose to hide the widget.
|
74
73
|
|
75
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.
|
76
75
|
To prevent this behaviour and better match the production, turn on cache_classes in your config/environments/development.rb:
|
@@ -90,24 +89,22 @@ If you are using `Rack::Deflater` middleware you won't see the small button in t
|
|
90
89
|
*RoRvsWild.com* makes it easy to monitor requests, background jobs and errors in your production and staging environment.
|
91
90
|
It also comes with some extra options listed below.
|
92
91
|
|
93
|
-
#### Measure any code
|
92
|
+
#### Measure any section of code
|
94
93
|
|
95
|
-
|
94
|
+
RorVsWild measures a lot of events such as SQL queries. But it might not be enough for you. There is a solution to measure any section of code to help you find the most hidden bottlenecks.
|
96
95
|
|
97
96
|
```ruby
|
98
|
-
|
99
|
-
|
97
|
+
# Measure a code given as a string
|
98
|
+
RorVsWild.measure("bubble_sort(array)")
|
100
99
|
|
101
|
-
|
100
|
+
# Measure a code given as a block
|
101
|
+
RorVsWild.measure { bubble_sort(array) }
|
102
102
|
|
103
|
-
|
104
|
-
RorVsWild.
|
103
|
+
# Measure a code given as a block with an optional description
|
104
|
+
RorVsWild.measure("Optional description") { bubble_sort(array) }
|
105
105
|
```
|
106
106
|
|
107
|
-
|
108
|
-
|
109
|
-
Note that Calling `measure_code` or `measure_block` inside or a request or a job will add a section.
|
110
|
-
That is convenient to profile finely parts of your code.
|
107
|
+
For each custom measure, a section is added with the file name and line number where it has been called.
|
111
108
|
|
112
109
|
#### Send errors manually
|
113
110
|
|
@@ -137,6 +134,18 @@ RorVsWild.record_error(exception, {something: "important"})
|
|
137
134
|
RorVsWild.catch_error(something: "important") { 1 / 0 }
|
138
135
|
```
|
139
136
|
|
137
|
+
It is also possible to pre-fill this context data at the begining of each request or job :
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
class ApplicationController < ActionController::Base
|
141
|
+
before_action :prefill_error_context
|
142
|
+
|
143
|
+
def prefill_error_context
|
144
|
+
RorVsWild.merge_error_context(something: "important")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
140
149
|
#### Ignore requests, jobs, exceptions and plugins
|
141
150
|
|
142
151
|
From the configuration file, you can tell RorVsWild to skip monitoring some requests, jobs, exceptions and plugins.
|
data/lib/rorvswild/agent.rb
CHANGED
@@ -16,7 +16,7 @@ module RorVsWild
|
|
16
16
|
|
17
17
|
def self.default_ignored_exceptions
|
18
18
|
if defined?(Rails)
|
19
|
-
|
19
|
+
ActionDispatch::ExceptionWrapper.rescue_responses.keys
|
20
20
|
else
|
21
21
|
[]
|
22
22
|
end
|
@@ -49,7 +49,7 @@ module RorVsWild
|
|
49
49
|
measure_block(code) { eval(code) }
|
50
50
|
end
|
51
51
|
|
52
|
-
def measure_block(name, kind = "code".freeze, &block)
|
52
|
+
def measure_block(name = nil, kind = "code".freeze, &block)
|
53
53
|
current_data ? measure_section(name, kind: kind, &block) : measure_job(name, &block)
|
54
54
|
end
|
55
55
|
|
@@ -113,6 +113,18 @@ module RorVsWild
|
|
113
113
|
current_data[:error]
|
114
114
|
end
|
115
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
|
+
|
116
128
|
def current_data
|
117
129
|
Thread.current[:rorvswild_data]
|
118
130
|
end
|
@@ -162,15 +174,16 @@ module RorVsWild
|
|
162
174
|
client.post_async("/errors".freeze, error: hash)
|
163
175
|
end
|
164
176
|
|
165
|
-
def exception_to_hash(exception,
|
177
|
+
def exception_to_hash(exception, context = nil)
|
166
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
|
167
180
|
{
|
168
181
|
line: line.to_i,
|
169
182
|
file: locator.relative_path(file),
|
170
183
|
message: exception.message,
|
171
184
|
backtrace: exception.backtrace || ["No backtrace"],
|
172
185
|
exception: exception.class.to_s,
|
173
|
-
extra_details:
|
186
|
+
extra_details: context,
|
174
187
|
environment: {
|
175
188
|
os: os_description,
|
176
189
|
user: Etc.getlogin,
|
@@ -2,7 +2,6 @@ module RorVsWild
|
|
2
2
|
module Plugin
|
3
3
|
class NetHttp
|
4
4
|
HTTP = "http".freeze
|
5
|
-
HTTPS = "https".freeze
|
6
5
|
|
7
6
|
def self.setup
|
8
7
|
return if !defined?(Net::HTTP)
|
@@ -21,9 +20,7 @@ module RorVsWild
|
|
21
20
|
|
22
21
|
def request_with_rorvswild(req, body = nil, &block)
|
23
22
|
return request_without_rorvswild(req, body, &block) if request_called_twice?
|
24
|
-
|
25
|
-
url = "#{req.method} #{scheme}://#{address}#{req.path}"
|
26
|
-
RorVsWild.agent.measure_section(url, kind: HTTP) do
|
23
|
+
RorVsWild.agent.measure_section("#{req.method} #{address}", kind: HTTP) do
|
27
24
|
request_without_rorvswild(req, body, &block)
|
28
25
|
end
|
29
26
|
end
|
@@ -18,7 +18,7 @@ module RorVsWild
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.commands_to_string(commands)
|
21
|
-
commands.map { |c| c[0]
|
21
|
+
commands.map { |c| c[0] }.join("\n".freeze)
|
22
22
|
end
|
23
23
|
|
24
24
|
APPENDABLE_COMMANDS = [:auth, :select]
|
data/lib/rorvswild/version.rb
CHANGED
data/lib/rorvswild.rb
CHANGED
@@ -23,6 +23,10 @@ module RorVsWild
|
|
23
23
|
@logger ||= initialize_logger
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.measure(code_or_name = nil, &block)
|
27
|
+
block ? measure_block(code_or_name, &block) : measure_code(code_or_name)
|
28
|
+
end
|
29
|
+
|
26
30
|
def self.measure_code(code)
|
27
31
|
agent ? agent.measure_code(code) : eval(code)
|
28
32
|
end
|
@@ -39,6 +43,10 @@ module RorVsWild
|
|
39
43
|
agent.record_error(exception, extra_details) if agent
|
40
44
|
end
|
41
45
|
|
46
|
+
def self.merge_error_context(hash)
|
47
|
+
agent.merge_error_context(hash) if agent
|
48
|
+
end
|
49
|
+
|
42
50
|
def self.initialize_logger(destination = nil)
|
43
51
|
if destination.respond_to?(:info) && destination.respond_to?(:warn) && destination.respond_to?(:error)
|
44
52
|
destination
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
- Antoine Marguerie
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Performances and errors insights for rails developers.
|
15
15
|
email:
|
@@ -62,8 +62,10 @@ files:
|
|
62
62
|
homepage: https://www.rorvswild.com
|
63
63
|
licenses:
|
64
64
|
- MIT
|
65
|
-
metadata:
|
66
|
-
|
65
|
+
metadata:
|
66
|
+
source_code_uri: https://github.com/BaseSecrete/rorvswild
|
67
|
+
changelog_uri: https://github.com/BaseSecrete/rorvswild/blob/master/CHANGELOG.md
|
68
|
+
post_install_message:
|
67
69
|
rdoc_options: []
|
68
70
|
require_paths:
|
69
71
|
- lib
|
@@ -78,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
80
|
- !ruby/object:Gem::Version
|
79
81
|
version: '0'
|
80
82
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
82
|
-
signing_key:
|
83
|
+
rubygems_version: 3.2.22
|
84
|
+
signing_key:
|
83
85
|
specification_version: 4
|
84
86
|
summary: Ruby on Rails applications monitoring
|
85
87
|
test_files: []
|