Sha256: fec47abdb7f3a0a5a9b2f4f1ae48dcb5dbfbd178d990908b7c30254d8e93b7fb

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 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(
            library: wrapped_request.type,
            uri: wrapped_request.uri,
            procedure: 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

8 entries across 8 versions & 1 rubygems

Version Path
newrelic_rpm-5.4.0.347 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-5.1.0.344 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-5.0.0.342 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.8.0.341 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.7.1.340 lib/new_relic/agent/instrumentation/http.rb
newrelic_rpm-4.7.0.339 lib/new_relic/agent/instrumentation/http.rb