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
38
39
|
# File 'lib/new_relic/agent/instrumentation/ethon/instrumentation.rb', line 13
def prep_easy(easy, parent = nil)
wrapped_request = NewRelic::Agent::HTTPClients::EthonHTTPRequest.new(easy)
segment = NewRelic::Agent::Tracer.start_external_request_segment(
library: wrapped_request.type,
uri: wrapped_request.uri,
procedure: wrapped_request.method,
parent: parent
)
segment.(wrapped_request)
callback = proc do
wrapped_response = NewRelic::Agent::HTTPClients::EthonHTTPResponse.new(easy)
segment.(wrapped_response)
if easy.return_code != :ok
e = NewRelic::Agent::NoticeableError.new(NOTICEABLE_ERROR_CLASS,
"return_code: >>#{easy.return_code}<<, response_code: >>#{easy.response_code}<<")
segment.notice_error(e)
end
::NewRelic::Agent::Transaction::Segment.finish(segment)
end
easy.on_complete { callback.call }
segment
end
|