Sha256: e83ad3f645bd20a6913ef7e6d65a575ad1622de903d13fc5923c7ccde4d3ad10

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 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 
  module Agent 
    module Instrumentation
      module NetHTTP
        def request_with_tracing(request)
          wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, 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
  
            # RUBY-1244 Disable further tracing in request to avoid double
            # counting if connection wasn't started (which calls request again).
            NewRelic::Agent.disable_all_tracing do
              response = NewRelic::Agent::Tracer.capture_segment_error segment do
                yield
              end
            end
  
            wrapped_response = NewRelic::Agent::HTTPClients::NetHTTPResponse.new response
            segment.process_response_headers wrapped_response
            response
          ensure
            segment.finish
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
newrelic_rpm-8.2.0 lib/new_relic/agent/instrumentation/net_http/instrumentation.rb
newrelic_rpm-8.1.0 lib/new_relic/agent/instrumentation/net_http/instrumentation.rb
newrelic_rpm-8.0.0 lib/new_relic/agent/instrumentation/net_http/instrumentation.rb
newrelic_rpm-7.2.0 lib/new_relic/agent/instrumentation/net_http/instrumentation.rb
newrelic_rpm-7.1.0 lib/new_relic/agent/instrumentation/net_http/instrumentation.rb
newrelic_rpm-7.0.0 lib/new_relic/agent/instrumentation/net_http/instrumentation.rb