Sha256: 78d62dcee69a79255f75dad405747eb53c0c11a6e49b229e83e0cd54d2de2b30

Contents?: true

Size: 933 Bytes

Versions: 7

Compression:

Stored size: 933 Bytes

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 HTTPrb
    def with_tracing(request)
      wrapped_request = ::NewRelic::Agent::HTTPClients::HTTPRequest.new(request)

      begin
        segment = NewRelic::Agent::Tracer.start_external_request_segment(
          library: wrapped_request.type,
          uri: wrapped_request.uri,
          procedure: wrapped_request.method
        )

        segment.add_request_headers wrapped_request

        response = NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }

        wrapped_response = ::NewRelic::Agent::HTTPClients::HTTPResponse.new response
        segment.process_response_headers wrapped_response

        response
      ensure
        segment.finish if segment
      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/httprb/instrumentation.rb
newrelic_rpm-8.8.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.7.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.6.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.5.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.4.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.3.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb