lib/new_relic/agent/instrumentation/curb/instrumentation.rb in newrelic_rpm-9.0.0 vs lib/new_relic/agent/instrumentation/curb/instrumentation.rb in newrelic_rpm-9.1.0

- old
+ new

@@ -79,11 +79,11 @@ # Trace as an External/Multiple call if the first request isn't serial. def perform_with_tracing return yield if first_request_is_serial? - trace_execution_scoped("External/Multiple/Curb::Multi/perform") do + trace_execution_scoped('External/Multiple/Curb::Multi/perform') do yield end end # Instrument the specified +request+ (a Curl::Easy object) @@ -105,11 +105,11 @@ install_completion_callback(request, wrapped_response, segment) install_failure_callback(request, wrapped_response, segment) request._nr_instrumented = true end rescue => err - NewRelic::Agent.logger.error("Untrapped exception", err) + NewRelic::Agent.logger.error('Untrapped exception', err) end # Create request and response adapter objects for the specified +request+ # NOTE: Although strange to wrap request and response at once, it works # because curb's callback mechanism updates the instantiated wrappers @@ -139,16 +139,16 @@ def install_completion_callback(request, wrapped_response, segment) original_callback = request.on_complete request._nr_original_on_complete = original_callback request.on_complete do |finished_request| begin - segment.process_response_headers(wrapped_response) if segment + segment&.process_response_headers(wrapped_response) ensure ::NewRelic::Agent::Transaction::Segment.finish(segment) # Make sure the existing completion callback is run, and restore the # on_complete callback to how it was before. - original_callback.call(finished_request) if original_callback + original_callback&.call(finished_request) remove_instrumentation_callbacks(request) end end end @@ -171,10 +171,10 @@ if segment noticeable_error = NewRelic::Agent::NoticeableError.new(error[0].name, error[-1]) segment.notice_error(noticeable_error) end ensure - original_callback.call(failed_request, error) if original_callback + original_callback&.call(failed_request, error) remove_failure_callback(failed_request) end end newrelic_callback.instance_variable_set(:@__newrelic_original_callback, original_callback)