rorvswild 1.0.0.pre.alpha3 → 1.0.0.pre.alpha4
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/lib/rorvswild/agent.rb +5 -4
- data/lib/rorvswild/location.rb +3 -1
- data/lib/rorvswild/plugin/active_record.rb +2 -0
- data/lib/rorvswild/plugin/net_http.rb +1 -1
- data/lib/rorvswild/plugin/redis.rb +9 -2
- data/lib/rorvswild/section.rb +10 -2
- data/lib/rorvswild/version.rb +1 -1
- data/test/plugin/redis_test.rb +9 -2
- data/test/rorvswild_test.rb +4 -0
- data/test/section_test.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df4365fa8eb745004ea5aa2496714a0dbcadbd32
|
4
|
+
data.tar.gz: c6d978d8c149b2af076aa1bf6a2ffd43ae63fc2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa70526436f2367dceb7c2f27262c59d0d779d5924357a5d0052d7a935ad463df4019b957dcb7784d608ddadcca0f85aa34fb664b4955553711d37a7fcdbd63
|
7
|
+
data.tar.gz: 7563b60608111f548d19b8704916a6f767e842f1feda942210d30c0cdb0e6f6b29bcffd54957d6927c15987fe542d206ddaf85d477d542128915e010661c4926
|
data/lib/rorvswild/agent.rb
CHANGED
@@ -58,13 +58,14 @@ module RorVsWild
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def measure_block(name, kind = "code".freeze, &block)
|
61
|
-
data[:name] ? measure_section(name, kind, &block) : measure_job(name, &block)
|
61
|
+
data[:name] ? measure_section(name, kind: kind, &block) : measure_job(name, &block)
|
62
62
|
end
|
63
63
|
|
64
|
-
def measure_section(name, kind
|
64
|
+
def measure_section(name, kind: "code", appendable_command: false, &block)
|
65
65
|
return block.call unless data[:name]
|
66
66
|
begin
|
67
67
|
RorVsWild::Section.start do |section|
|
68
|
+
section.appendable_command = appendable_command
|
68
69
|
section.command = name
|
69
70
|
section.kind = kind
|
70
71
|
end
|
@@ -159,7 +160,7 @@ module RorVsWild
|
|
159
160
|
end
|
160
161
|
|
161
162
|
def post_error(hash)
|
162
|
-
post_async("/errors".freeze, error: hash)
|
163
|
+
client.post_async("/errors".freeze, error: hash)
|
163
164
|
end
|
164
165
|
|
165
166
|
def exception_to_hash(exception, extra_details = nil)
|
@@ -168,7 +169,7 @@ module RorVsWild
|
|
168
169
|
line: line.to_i,
|
169
170
|
file: relative_path(file),
|
170
171
|
message: exception.message,
|
171
|
-
backtrace: exception.backtrace,
|
172
|
+
backtrace: exception.backtrace || ["No backtrace"],
|
172
173
|
exception: exception.class.to_s,
|
173
174
|
extra_details: extra_details,
|
174
175
|
}
|
data/lib/rorvswild/location.rb
CHANGED
@@ -15,8 +15,10 @@ module RorVsWild
|
|
15
15
|
# Sometime Exception#backtrace_locations returns nil for an unknow reason. So we fallback to the old way.
|
16
16
|
if exception.respond_to?(:backtrace_locations) && locations = exception.backtrace_locations
|
17
17
|
extract_most_relevant_file_and_line(locations)
|
18
|
+
elsif backtrace = exception.backtrace
|
19
|
+
extract_most_relevant_file_and_line_from_array_of_strings(backtrace)
|
18
20
|
else
|
19
|
-
|
21
|
+
["No backtrace".freeze, 1]
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -13,10 +13,12 @@ module RorVsWild
|
|
13
13
|
end
|
14
14
|
|
15
15
|
IGNORED_QUERIES = %w[EXPLAIN SCHEMA].freeze
|
16
|
+
APPENDABLE_QUERIES = ["BEGIN", "COMMIT"].freeze
|
16
17
|
|
17
18
|
def start(name, id, payload)
|
18
19
|
return if IGNORED_QUERIES.include?(payload[:name])
|
19
20
|
RorVsWild::Section.start do |section|
|
21
|
+
section.appendable_command = APPENDABLE_QUERIES.include?(payload[:sql])
|
20
22
|
section.command = payload[:sql]
|
21
23
|
section.kind = "sql".freeze
|
22
24
|
end
|
@@ -15,7 +15,7 @@ module RorVsWild
|
|
15
15
|
return request_without_rorvswild(req, body, &block) if request_called_twice?
|
16
16
|
scheme = use_ssl? ? HTTPS : HTTP
|
17
17
|
url = "#{req.method} #{scheme}://#{address}#{req.path}"
|
18
|
-
RorVsWild.agent.measure_section(url, HTTP) do
|
18
|
+
RorVsWild.agent.measure_section(url, kind: HTTP) do
|
19
19
|
request_without_rorvswild(req, body, &block)
|
20
20
|
end
|
21
21
|
end
|
@@ -9,7 +9,8 @@ module RorVsWild
|
|
9
9
|
|
10
10
|
def process(commands, &block)
|
11
11
|
string = RorVsWild::Plugin::Redis.commands_to_string(commands)
|
12
|
-
RorVsWild.
|
12
|
+
appendable = RorVsWild::Plugin::Redis.appendable_commands?(commands)
|
13
|
+
RorVsWild.agent.measure_section(string, appendable_command: appendable, kind: "redis".freeze) do
|
13
14
|
process_without_rorvswild(commands, &block)
|
14
15
|
end
|
15
16
|
end
|
@@ -17,7 +18,13 @@ module RorVsWild
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.commands_to_string(commands)
|
20
|
-
commands.map { |c| c[0] == :auth ? "auth *****" : c.join(" ".freeze) }.join("\n".freeze)
|
21
|
+
commands.map { |c| c[0] == :auth ? "auth *****".freeze : c.join(" ".freeze) }.join("\n".freeze)
|
22
|
+
end
|
23
|
+
|
24
|
+
APPENDABLE_COMMANDS = [:auth, :select]
|
25
|
+
|
26
|
+
def self.appendable_commands?(commands)
|
27
|
+
commands.size == 1 && APPENDABLE_COMMANDS.include?(commands.first.first)
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
data/lib/rorvswild/section.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RorVsWild
|
2
2
|
class Section
|
3
3
|
attr_reader :started_at
|
4
|
-
attr_accessor :kind, :file, :line, :calls, :command, :children_runtime, :total_runtime
|
4
|
+
attr_accessor :kind, :file, :line, :calls, :command, :children_runtime, :total_runtime, :appendable_command
|
5
5
|
|
6
6
|
def self.start(&block)
|
7
7
|
section = Section.new
|
@@ -34,17 +34,25 @@ module RorVsWild
|
|
34
34
|
location = RorVsWild.agent.find_most_relevant_location(caller_locations)
|
35
35
|
@file = RorVsWild.agent.relative_path(location.path)
|
36
36
|
@line = location.lineno
|
37
|
+
@appendable_command = false
|
37
38
|
end
|
38
39
|
|
39
40
|
def sibling?(section)
|
40
41
|
kind == section.kind && line == section.line && file == section.file
|
41
42
|
end
|
42
43
|
|
44
|
+
MAX_COMMAND_HISTORY = 5
|
45
|
+
|
43
46
|
def merge(section)
|
44
47
|
self.calls += section.calls
|
45
48
|
self.total_runtime += section.total_runtime
|
46
49
|
self.children_runtime += section.children_runtime
|
47
|
-
|
50
|
+
if section
|
51
|
+
self.command << "\n".freeze + section.command if appendable_command
|
52
|
+
else
|
53
|
+
self.command = section.command
|
54
|
+
end
|
55
|
+
self.appendable_command = appendable_command && section.appendable_command
|
48
56
|
end
|
49
57
|
|
50
58
|
def self_runtime
|
data/lib/rorvswild/version.rb
CHANGED
data/test/plugin/redis_test.rb
CHANGED
@@ -6,10 +6,11 @@ class RorVsWild::Plugin::RedisTest < Minitest::Test
|
|
6
6
|
include RorVsWildAgentHelper
|
7
7
|
|
8
8
|
def test_callback
|
9
|
-
|
9
|
+
url = "redis://localhost:6379/1"
|
10
|
+
agent.measure_code("::Redis.new(url: '#{url}').get('foo')")
|
10
11
|
assert_equal(1, agent.data[:sections].size)
|
11
12
|
assert_equal("redis", agent.data[:sections][0].kind)
|
12
|
-
assert_equal("
|
13
|
+
assert_equal("select 1\nget foo", agent.data[:sections][0].command)
|
13
14
|
end
|
14
15
|
|
15
16
|
def test_callback_when_pipelined
|
@@ -27,4 +28,10 @@ class RorVsWild::Plugin::RedisTest < Minitest::Test
|
|
27
28
|
def test_commands_to_string_hide_auth_password
|
28
29
|
assert_equal("auth *****", RorVsWild::Plugin::Redis.commands_to_string([[:auth, "SECRET"]]))
|
29
30
|
end
|
31
|
+
|
32
|
+
def test_appendable_commands?
|
33
|
+
assert(RorVsWild::Plugin::Redis.appendable_commands?([[:select, 1]]))
|
34
|
+
assert(RorVsWild::Plugin::Redis.appendable_commands?([[:auth, "SECRET"]]))
|
35
|
+
refute(RorVsWild::Plugin::Redis.appendable_commands?([[:get, "KEY"]]))
|
36
|
+
end
|
30
37
|
end
|
data/test/rorvswild_test.rb
CHANGED
@@ -134,6 +134,10 @@ class RorVsWildTest < Minitest::Test
|
|
134
134
|
assert_equal(["#{ENV["GEM_HOME"]}/lib/sql.rb", "1"], agent.extract_most_relevant_file_and_line_from_array_of_strings(locations))
|
135
135
|
end
|
136
136
|
|
137
|
+
def test_extract_most_relevant_file_and_line_from_exception_when_exception_has_no_backtrace
|
138
|
+
assert_equal(["No backtrace", 1], agent.extract_most_relevant_file_and_line_from_exception(StandardError.new))
|
139
|
+
end
|
140
|
+
|
137
141
|
private
|
138
142
|
|
139
143
|
def agent
|
data/test/section_test.rb
CHANGED
@@ -21,6 +21,12 @@ class RorVsWild::SectionTest < Minitest::Test
|
|
21
21
|
assert_equal(3, section1.calls)
|
22
22
|
assert_equal(3, section1.total_runtime)
|
23
23
|
assert_equal(3, section1.children_runtime)
|
24
|
+
assert_equal("command1", section1.command)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_merge_with_appendable_command
|
28
|
+
section3.merge(section1)
|
29
|
+
assert_equal("command3\ncommand1", section3.command)
|
24
30
|
end
|
25
31
|
|
26
32
|
def section1
|
@@ -32,6 +38,7 @@ class RorVsWild::SectionTest < Minitest::Test
|
|
32
38
|
s.calls = 1
|
33
39
|
s.total_runtime = 1
|
34
40
|
s.children_runtime = 1
|
41
|
+
s.command = "command1"
|
35
42
|
@section1 = s
|
36
43
|
end
|
37
44
|
@section1
|
@@ -46,8 +53,25 @@ class RorVsWild::SectionTest < Minitest::Test
|
|
46
53
|
s.calls = 2
|
47
54
|
s.total_runtime = 2
|
48
55
|
s.children_runtime = 2
|
56
|
+
s.command = "command2"
|
49
57
|
@section2 = s
|
50
58
|
end
|
51
59
|
@section2
|
52
60
|
end
|
61
|
+
|
62
|
+
def section3
|
63
|
+
unless @section3
|
64
|
+
s = RorVsWild::Section.new
|
65
|
+
s.kind = "test"
|
66
|
+
s.file = "file"
|
67
|
+
s.line = 3
|
68
|
+
s.calls = 0
|
69
|
+
s.total_runtime = 3
|
70
|
+
s.children_runtime = 3
|
71
|
+
s.command = "command3"
|
72
|
+
s.appendable_command = true
|
73
|
+
@section3 = s
|
74
|
+
end
|
75
|
+
@section3
|
76
|
+
end
|
53
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.alpha4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|