7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rorvswild/plugin/net_http.rb', line 7
def self.setup
return if !defined?(Net::HTTP)
return if Net::HTTP.method_defined?(:request_without_rorvswild)
Net::HTTP.class_eval do
alias_method :request_without_rorvswild, :request
def request(req, body = nil, &block)
if Thread.current[:rorvswild_ignore_net_http]
request_without_rorvswild(req, body, &block)
else
request_with_rorvswild(req, body, &block)
end
end
def request_with_rorvswild(req, body = nil, &block)
return request_without_rorvswild(req, body, &block) if request_called_twice?
scheme = use_ssl? ? HTTPS : HTTP
url = "#{req.method} #{scheme}://#{address}#{req.path}"
RorVsWild.agent.measure_section(url, kind: HTTP) do
request_without_rorvswild(req, body, &block)
end
end
def request_called_twice?
(current_section = RorVsWild::Section.current) && current_section.kind == HTTP
end
end
end
|