Sha256: f1dda8508c0eab52cb569964d6ee00505568e06308a64d5485b074fc9ad0d72f

Contents?: true

Size: 978 Bytes

Versions: 13

Compression:

Stored size: 978 Bytes

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
newrelic_rpm-9.4.2 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.4.1 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.4.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.3.1 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.3.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.2.2 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.2.1 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.2.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.1.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-9.0.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.16.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.15.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb
newrelic_rpm-8.14.0 lib/new_relic/agent/instrumentation/httprb/instrumentation.rb