Sha256: 32629983e6c9d200ed71a2fcf1ecfcb3d9d1616872f1dcbfb8f76c7ae017ecee

Contents?: true

Size: 966 Bytes

Versions: 2

Compression:

Stored size: 966 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.
# frozen_string_literal: true

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

2 entries across 2 versions & 1 rubygems

Version Path
newrelic_rpm-8.10.1 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.10.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb