lib/opentelemetry/sdk/trace/export/batch_span_processor.rb in opentelemetry-sdk-0.14.0 vs lib/opentelemetry/sdk/trace/export/batch_span_processor.rb in opentelemetry-sdk-0.15.0

- old
+ new

@@ -26,11 +26,12 @@ # worker thread that exports the spans to wake up and start a new # export cycle. class BatchSpanProcessor # rubocop:disable Metrics/ClassLength # Returns a new instance of the {BatchSpanProcessor}. # - # @param [SpanExporter] exporter + # @param [SpanExporter] exporter the (duck type) SpanExporter to where the + # recorded Spans are pushed after batching. # @param [Numeric] exporter_timeout the delay interval between two # consecutive exports. Defaults to the value of the OTEL_BSP_EXPORT_TIMEOUT # environment variable, if set, or 30,000 (30 seconds). # @param [Numeric] schedule_delay the maximum allowed time to export data. # Defaults to the value of the OTEL_BSP_SCHEDULE_DELAY environment @@ -41,11 +42,11 @@ # @param [Integer] max_export_batch_size the maximum batch size in spans. # Defaults to the value of the OTEL_BSP_MAX_EXPORT_BATCH_SIZE environment # variable, if set, or 512. # # @return a new instance of the {BatchSpanProcessor}. - def initialize(exporter:, + def initialize(exporter, exporter_timeout: Float(ENV.fetch('OTEL_BSP_EXPORT_TIMEOUT', 30_000)), schedule_delay: Float(ENV.fetch('OTEL_BSP_SCHEDULE_DELAY', 5_000)), max_queue_size: Integer(ENV.fetch('OTEL_BSP_MAX_QUEUE_SIZE', 2048)), max_export_batch_size: Integer(ENV.fetch('OTEL_BSP_MAX_EXPORT_BATCH_SIZE', 512)), start_thread_on_boot: String(ENV['OTEL_RUBY_BSP_START_THREAD_ON_BOOT']) !~ /false/i, @@ -174,9 +175,12 @@ return if @pid == pid @pid = pid spans.clear @thread = restart_thread ? Thread.new { work } : nil + rescue ThreadError => e + @metrics_reporter.add_to_counter('otel.bsp.error', labels: { 'reason' => 'ThreadError' }) + OpenTelemetry.handle_error(exception: e, message: 'unexpected error in BatchSpanProcessor#reset_on_fork') end def export_batch(batch, timeout: @exporter_timeout_seconds) result_code = @export_mutex.synchronize { @exporter.export(batch, timeout: timeout) } report_result(result_code, batch)