Sha256: 1b70b977e63ee691abd6d34102d1c6aeb129e6c94d66c4ef5a4c59a6a993163d

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

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

module NewRelic::Agent::Instrumentation
  module HTTPClient
    module Instrumentation
      INSTRUMENTATION_NAME = 'HTTPClient'

      def with_tracing(request, connection)
        NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

        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
          ::NewRelic::Agent::Transaction::Segment.finish(segment)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
newrelic_rpm-9.17.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.16.1 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.16.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.15.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.14.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.13.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.12.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.11.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.10.2 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.10.1 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.10.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.9.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.8.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.7.1 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.7.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.6.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb
newrelic_rpm-9.5.0 lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb