4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/simple_apm/net_http.rb', line 4
def install
Net::HTTP.class_eval do
alias orig_request_apm request unless method_defined?(:orig_request)
def request(req, body = nil, &block)
url = if @port == '80'
"http://#{@address}#{req.path}"
elsif @port == '443'
"https://#{@address}#{req.path}"
else
"http://#{@address}:#{@port}#{req.path}"
end
if started?
ActiveSupport::Notifications.instrument "net_http.request", url: url, host: @address, path: req.path do
@response = orig_request_apm(req, body, &block)
end
else
@response = orig_request_apm(req, body, &block)
end
@response
end
end
end
|