module NewRelic::Agent::Instrumentation::Ethon::NRShared
Constants
- INSTRUMENTATION_NAME
- NOTICEABLE_ERROR_CLASS
Public Instance Methods
prep_easy(easy, parent = nil)
click to toggle source
# 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.add_request_headers(wrapped_request) callback = proc do wrapped_response = NewRelic::Agent::HTTPClients::EthonHTTPResponse.new(easy) segment.process_response_headers(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
wrap_with_tracing(segment) { || ... }
click to toggle source
# File lib/new_relic/agent/instrumentation/ethon/instrumentation.rb, line 41 def wrap_with_tracing(segment, &block) NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME) NewRelic::Agent::Tracer.capture_segment_error(segment) do yield end ensure NewRelic::Agent::Transaction::Segment.finish(segment) end