Sha256: 4b2cfcc9b0f6d5750a1c6627475e7833c1ad1117fc997f358283c32415f63f2c

Contents?: true

Size: 1.38 KB

Versions: 20

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

DependencyDetection.defer do
  named :httpclient

  HTTPCLIENT_MIN_VERSION = '2.2.0'

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

  depends_on do
    minimum_supported_version = NewRelic::VersionNumber.new(HTTPCLIENT_MIN_VERSION)
    current_version = NewRelic::VersionNumber.new(HTTPClient::VERSION)

    current_version >= minimum_supported_version
  end

  executes do
    ::NewRelic::Agent.logger.info 'Installing HTTPClient instrumentation'
    require 'new_relic/agent/cross_app_tracing'
    require 'new_relic/agent/http_clients/httpclient_wrappers'
  end

  executes do
    class HTTPClient
      def do_get_block_with_newrelic(req, proxy, conn, &block)
        wrapped_request = NewRelic::Agent::HTTPClients::HTTPClientRequest.new(req)

        response = nil
        ::NewRelic::Agent::CrossAppTracing.trace_http_request(wrapped_request) do
          do_get_block_without_newrelic(req, proxy, conn, &block)
          response = conn.pop
          conn.push response
          ::NewRelic::Agent::HTTPClients::HTTPClientResponse.new(response)
        end
        response
      end

      alias do_get_block_without_newrelic do_get_block
      alias do_get_block do_get_block_with_newrelic
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
newrelic_rpm-3.9.0.229 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.8.1.221 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.8.0.218 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.3.204 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.3.199 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.2.195 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.2.192 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.2.190.beta lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.1.188 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.1.182 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.1.180 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.0.177 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.7.0.174.beta lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.6.9.171 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.6.8.168 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.6.8.164 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.6.7.159 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.6.7.159.beta lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.6.7.152 lib/new_relic/agent/instrumentation/httpclient.rb
newrelic_rpm-3.6.6.147 lib/new_relic/agent/instrumentation/httpclient.rb