From a6a8842664ff3fdcae52299a88a376dbe63567a8 Mon Sep 17 00:00:00 2001 From: Ian Quick Date: Wed, 11 Sep 2019 10:20:54 -0400 Subject: [PATCH] whoops fetching batch should be in the lock --- .../sdk/trace/export/batch_sampled_span_processor.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/lib/opentelemetry/sdk/trace/export/batch_sampled_span_processor.rb b/sdk/lib/opentelemetry/sdk/trace/export/batch_sampled_span_processor.rb index afd312308..09da64360 100644 --- a/sdk/lib/opentelemetry/sdk/trace/export/batch_sampled_span_processor.rb +++ b/sdk/lib/opentelemetry/sdk/trace/export/batch_sampled_span_processor.rb @@ -70,6 +70,7 @@ def shutdown def work loop do keep_running = nil + batch = nil lock do if spans.size < max_queue_size loop do @@ -78,9 +79,10 @@ def work end end keep_running = @keep_running + batch = fetch_batch end # this is done outside the lock to unblock the producers - @exporter.export(fetch_batch) + @exporter.export(batch) break unless keep_running end flush @@ -96,7 +98,7 @@ def fetch_batch batch = [] loop do break if batch.size >= @batch_size || spans.empty? - batch << spans.shift + batch << spans.shift.to_span_proto end batch end