lib/ddtrace/workers.rb in ddtrace-0.45.0 vs lib/ddtrace/workers.rb in ddtrace-0.46.0
- old
+ new
@@ -65,13 +65,17 @@
# Start the timer execution.
def start
@mutex.synchronize do
return if @run
+
@run = true
Datadog.logger.debug("Starting thread in the process: #{Process.pid}")
@worker = Thread.new { perform }
+ @worker.name = self.class.name unless Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
+
+ nil
end
end
# Closes all available queues and waits for the trace buffer to flush
def stop
@@ -106,9 +110,10 @@
loop do
@back_off = flush_data ? @flush_interval : [@back_off * BACK_OFF_RATIO, BACK_OFF_MAX].min
@mutex.synchronize do
return if !@run && @trace_buffer.empty?
+
@shutdown.wait(@mutex, @back_off) if @run # do not wait when shutting down
end
end
end
end