Sha256: 4a1969e9e46d2dfa4ebeb6122a21ae23ce1c1b2c80dde3ee1669129ba534dff2

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 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 :httprb

  depends_on do
    defined?(HTTP) && defined?(HTTP::Client)
  end

  executes do
    ::NewRelic::Agent.logger.info 'Installing http.rb instrumentation'
    require 'new_relic/agent/cross_app_tracing'
    require 'new_relic/agent/http_clients/http_rb_wrappers'
  end

  executes do
    class HTTP::Client
      def perform_with_newrelic_trace(request, options)
        wrapped_request = ::NewRelic::Agent::HTTPClients::HTTPRequest.new(request)

        begin
          segment = NewRelic::Agent::Transaction.start_external_request_segment(
            wrapped_request.type, wrapped_request.uri, wrapped_request.method)

          segment.add_request_headers wrapped_request

          response = perform_without_newrelic_trace(request, options)
          wrapped_response = ::NewRelic::Agent::HTTPClients::HTTPResponse.new response
          segment.read_response_headers wrapped_response

          response
        ensure
          segment.finish if segment
        end
      end

      alias perform_without_newrelic_trace perform
      alias perform perform_with_newrelic_trace
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
newrelic_rpm-4.6.0.338 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.5.0.337 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.4.0.336 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.3.0.335 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.2.0.334 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.1.0.333 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.0.0.332 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-3.18.1.330 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-3.18.0.329 lib/new_relic/agent/instrumentation/http.rb