# encoding: utf-8 LibraryDetection.defer do named :httpclient HTTPCLIENT_MINIMUM_VERSION = '2.2.0' depends_on do defined?(HTTPClient) && defined?(HTTPClient::VERSION) end depends_on do minimum_supported_version = OneApm::VersionNumber.new(HTTPCLIENT_MINIMUM_VERSION) current_version = OneApm::VersionNumber.new(HTTPClient::VERSION) current_version >= minimum_supported_version end executes do OneApm::Manager.logger.info 'Installing HTTPClient instrumentation' require 'one_apm/agent/cross_app/cross_app_tracing' require 'one_apm/support/http_clients/httpclient_wrappers' end executes do class HTTPClient def do_get_block_with_oneapm(req, proxy, conn, &block) wrapped_request = OneApm::Support::HTTPClients::HTTPClientRequest.new(req) response = nil ::OneApm::Agent::CrossAppTracing.tl_trace_http_request(wrapped_request) do do_get_block_without_oneapm(req, proxy, conn, &block) response = conn.pop conn.push response ::OneApm::Support::HTTPClients::HTTPClientResponse.new(response) end response end alias do_get_block_without_oneapm do_get_block alias do_get_block do_get_block_with_oneapm end end end