rorvswild 1.1.1 → 1.2.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/Gemfile +1 -0
- data/lib/rorvswild/agent.rb +1 -0
- data/lib/rorvswild/plugin/elasticsearch.rb +23 -0
- data/lib/rorvswild/plugin/net_http.rb +16 -0
- data/lib/rorvswild/plugins.rb +1 -0
- data/lib/rorvswild/section.rb +0 -2
- data/lib/rorvswild/version.rb +1 -1
- data/test/helper.rb +1 -1
- data/test/plugin/elasticsearch_test.rb +17 -0
- data/test/queue_test.rb +6 -2
- data/test/rorvswild_test.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbddf42d7a3d87901206dcdb0872b689c733b100
|
4
|
+
data.tar.gz: 51c9aeebb5d2ec07863465db44f2253990421336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b109fabeb568743f2d306c8295bdb4201fa01773fb0940c9c2c8ebe1679426fe91969d56fa3c6c02217ef91e9f4241b23eac881a68ef276f6354b86c4eb69f4
|
7
|
+
data.tar.gz: e20ff2a1eae18fbaa31e4631f7a6093ce7b97be390ddc0acea6a6e6483820a1cefe7737572a439c90442d8299c79a119998c9ba33fee635f90d4c3194fadc8d4
|
data/Gemfile
CHANGED
data/lib/rorvswild/agent.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module RorVsWild
|
2
|
+
module Plugin
|
3
|
+
class Elasticsearch
|
4
|
+
def self.setup
|
5
|
+
return if !defined?(::Elasticsearch::Transport)
|
6
|
+
return if ::Elasticsearch::Transport::Client.method_defined?(:perform_request_without_rorvswild)
|
7
|
+
|
8
|
+
::Elasticsearch::Transport::Client.class_eval do
|
9
|
+
alias_method :perform_request_without_rorvswild, :perform_request
|
10
|
+
|
11
|
+
def perform_request(method, path, params={}, body=nil)
|
12
|
+
RorVsWild::Plugin::NetHttp.ignore do
|
13
|
+
command = {method: method, path: path, params: params, body: body}.to_json
|
14
|
+
RorVsWild.agent.measure_section(command, kind: "elasticsearch") do
|
15
|
+
perform_request_without_rorvswild(method, path, params, body)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -12,6 +12,14 @@ module RorVsWild
|
|
12
12
|
alias_method :request_without_rorvswild, :request
|
13
13
|
|
14
14
|
def request(req, body = nil, &block)
|
15
|
+
if Thread.current[:rorvswild_ignore_net_http]
|
16
|
+
request_without_rorvswild(req, body, &block)
|
17
|
+
else
|
18
|
+
request_with_rorvswild(req, body, &block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def request_with_rorvswild(req, body = nil, &block)
|
15
23
|
return request_without_rorvswild(req, body, &block) if request_called_twice?
|
16
24
|
scheme = use_ssl? ? HTTPS : HTTP
|
17
25
|
url = "#{req.method} #{scheme}://#{address}#{req.path}"
|
@@ -27,6 +35,14 @@ module RorVsWild
|
|
27
35
|
end
|
28
36
|
end
|
29
37
|
end
|
38
|
+
|
39
|
+
def self.ignore(&block)
|
40
|
+
old_value = Thread.current[:rorvswild_ignore_net_http]
|
41
|
+
Thread.current[:rorvswild_ignore_net_http] = true
|
42
|
+
block.call
|
43
|
+
ensure
|
44
|
+
Thread.current[:rorvswild_ignore_net_http] = old_value
|
45
|
+
end
|
30
46
|
end
|
31
47
|
end
|
32
48
|
end
|
data/lib/rorvswild/plugins.rb
CHANGED
data/lib/rorvswild/section.rb
CHANGED
data/lib/rorvswild/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
+
|
3
|
+
require "elasticsearch"
|
4
|
+
|
5
|
+
class RorVsWild::Plugin::ElasticsearchTest < Minitest::Test
|
6
|
+
include RorVsWildAgentHelper
|
7
|
+
|
8
|
+
def test_callback
|
9
|
+
agent.measure_block("elastic") do
|
10
|
+
::Elasticsearch::Client.new.search(q: "test")
|
11
|
+
end
|
12
|
+
assert_equal(1, agent.data[:sections].size)
|
13
|
+
assert_equal(1, agent.data[:sections][0].calls)
|
14
|
+
assert_equal("elasticsearch", agent.data[:sections][0].kind)
|
15
|
+
assert_equal('{"method":"GET","path":"_search","params":{"q":"test"},"body":null}', agent.data[:sections][0].command)
|
16
|
+
end
|
17
|
+
end
|
data/test/queue_test.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
require File.expand_path("#{File.dirname(__FILE__)}/helper")
|
2
2
|
|
3
3
|
class QueueTest < Minitest::Test
|
4
|
+
include RorVsWildAgentHelper
|
5
|
+
|
4
6
|
def test_push_job
|
7
|
+
queue.start_thread
|
5
8
|
queue.thread.expects(:wakeup)
|
6
9
|
10.times { queue.push_job(1) }
|
7
10
|
assert_equal(10, queue.jobs.size)
|
8
11
|
end
|
9
12
|
|
10
13
|
def test_push_request
|
14
|
+
queue.start_thread
|
11
15
|
queue.thread.expects(:wakeup)
|
12
16
|
10.times { queue.push_request(1) }
|
13
17
|
assert_equal(10, queue.requests.size)
|
@@ -43,10 +47,10 @@ class QueueTest < Minitest::Test
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def queue
|
46
|
-
@queue ||=
|
50
|
+
@queue ||= agent.instance_variable_get(:@queue)
|
47
51
|
end
|
48
52
|
|
49
53
|
def client
|
50
|
-
@client ||=
|
54
|
+
@client ||= agent.instance_variable_get(:@client)
|
51
55
|
end
|
52
56
|
end
|
data/test/rorvswild_test.rb
CHANGED
@@ -145,7 +145,7 @@ class RorVsWildTest < Minitest::Test
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def initialize_agent(options = {})
|
148
|
-
agent ||= RorVsWild.start(options)
|
148
|
+
agent ||= RorVsWild.start({logger: "/dev/null"}.merge(options))
|
149
149
|
agent.stubs(:post_request)
|
150
150
|
agent.stubs(:post_task)
|
151
151
|
agent
|
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.
|
4
|
+
version: 1.2.0
|
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-11-
|
11
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Performances and quality insights for rails developers.
|
14
14
|
email:
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/rorvswild/plugin/active_job.rb
|
37
37
|
- lib/rorvswild/plugin/active_record.rb
|
38
38
|
- lib/rorvswild/plugin/delayed_job.rb
|
39
|
+
- lib/rorvswild/plugin/elasticsearch.rb
|
39
40
|
- lib/rorvswild/plugin/mongo.rb
|
40
41
|
- lib/rorvswild/plugin/net_http.rb
|
41
42
|
- lib/rorvswild/plugin/redis.rb
|
@@ -55,6 +56,7 @@ files:
|
|
55
56
|
- test/plugin/active_job_test.rb
|
56
57
|
- test/plugin/active_record_test.rb
|
57
58
|
- test/plugin/delayed_job_test.rb
|
59
|
+
- test/plugin/elasticsearch_test.rb
|
58
60
|
- test/plugin/mongo_test.rb
|
59
61
|
- test/plugin/net_http_test.rb
|
60
62
|
- test/plugin/redis_test.rb
|
@@ -97,6 +99,7 @@ test_files:
|
|
97
99
|
- test/plugin/active_job_test.rb
|
98
100
|
- test/plugin/active_record_test.rb
|
99
101
|
- test/plugin/delayed_job_test.rb
|
102
|
+
- test/plugin/elasticsearch_test.rb
|
100
103
|
- test/plugin/mongo_test.rb
|
101
104
|
- test/plugin/net_http_test.rb
|
102
105
|
- test/plugin/redis_test.rb
|