Sha256: e09ef383e51c222295872b99998886b63470040d31bb7c2580d065d73920af6a

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

LibraryDetection.defer do
  named :httpclient

  OA_HTTPCLIENT_MINIMUM_VERSION = '2.2.0'

  depends_on do
    defined?(HTTPClient) && defined?(HTTPClient::VERSION)
  end

  depends_on do
    minimum_supported_version = OneApm::VersionNumber.new(OA_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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oneapm_rpm-1.4.2 lib/one_apm/inst/http_clients/httpclient.rb
oneapm_rpm-1.4.1 lib/one_apm/inst/http_clients/httpclient.rb
oneapm_rpm-1.4.0 lib/one_apm/inst/http_clients/httpclient.rb
oneapm_rpm-1.3.7 lib/one_apm/inst/http_clients/httpclient.rb
oneapm_rpm-1.3.7.rc1 lib/one_apm/inst/http_clients/httpclient.rb