Sha256: 2e9579a5d8a1c92255b21cc4732a3a2f25f231c8a5e6d86875d8820448e1f244

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

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

module NewRelic::Agent::Instrumentation
  module HTTPClient
    module Instrumentation
      def with_tracing request, connection
        wrapped_request = NewRelic::Agent::HTTPClients::HTTPClientRequest.new(request)
        segment = NewRelic::Agent::Tracer.start_external_request_segment(
          library: wrapped_request.type,
          uri: wrapped_request.uri,
          procedure: wrapped_request.method
        )

        begin
          response = nil
          segment.add_request_headers wrapped_request

          NewRelic::Agent::Tracer.capture_segment_error segment do
            yield
          end

          response = connection.pop
          connection.push response

          wrapped_response = ::NewRelic::Agent::HTTPClients::HTTPClientResponse.new(response)
          segment.process_response_headers wrapped_response

          response
        ensure
          segment.finish if segment
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
newrelic_rpm-8.9.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-8.8.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-8.7.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-8.6.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-8.5.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-8.4.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-8.3.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb