lib/ddtrace/workers.rb in ddtrace-0.13.0 vs lib/ddtrace/workers.rb in ddtrace-0.13.1

- old
+ new

@@ -41,11 +41,11 @@ @trace_task.call(traces, @transport) rescue StandardError => e # ensures that the thread will not die because of an exception. # TODO[manu]: findout the reason and reschedule the send if it's not # a fatal exception - Datadog::Tracer.log.error("Error during traces flush: dropped #{items.length} items. Cause: #{e}") + Datadog::Tracer.log.error("Error during traces flush: dropped #{traces.length} items. Cause: #{e}") end end # Callback function that process traces and executes the +send_services()+ method. def callback_services @@ -56,11 +56,11 @@ @service_task.call(services[0], @transport) rescue StandardError => e # ensures that the thread will not die because of an exception. # TODO[manu]: findout the reason and reschedule the send if it's not # a fatal exception - Datadog::Tracer.log.error("Error during services flush: dropped #{items.length} items. Cause: #{e}") + Datadog::Tracer.log.error("Error during services flush: dropped #{services.length} items. Cause: #{e}") end end # Start the timer execution. def start @@ -104,18 +104,20 @@ @service_buffer.push(service) end private + alias flush_data callback_traces + def perform loop do - @back_off = callback_traces ? @flush_interval : [@back_off * BACK_OFF_RATIO, BACK_OFF_MAX].min + @back_off = flush_data ? @flush_interval : [@back_off * BACK_OFF_RATIO, BACK_OFF_MAX].min callback_services @mutex.synchronize do return if !@run && @trace_buffer.empty? && @service_buffer.empty? - @shutdown.wait(@mutex, @back_off) + @shutdown.wait(@mutex, @back_off) if @run # do not wait when shutting down end end end end end