lib/new_relic/agent/agent.rb in newrelic_rpm-6.11.0.365 vs lib/new_relic/agent/agent.rb in newrelic_rpm-6.12.0.367

- old
+ new

@@ -1,8 +1,8 @@ # encoding: utf-8 # This file is distributed under New Relic's license terms. -# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details. +# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. require 'socket' require 'net/https' require 'net/http' require 'logger' @@ -242,9 +242,16 @@ def revert_to_default_configuration Agent.config.remove_config_type(:manual) Agent.config.remove_config_type(:server) end + # If the @worker_thread encounters an error during the attempt to connect to the collector + # then the connect attempts enter an exponential backoff retry loop. To avoid potential + # race conditions with shutting down while also attempting to reconnect, we join the + # @worker_thread with a timeout threshold. This allows potentially connecting and flushing + # pending data to the server, but without waiting indefinitely for a reconnect to succeed. + # The use-case where this typically arises is in cronjob scheduled rake tasks where there's + # also some network stability/latency issues happening. def stop_event_loop @event_loop.stop if @event_loop # Wait the end of the event loop thread. if @worker_thread unless @worker_thread.join(3)