lib/opentelemetry/sdk/trace/export/batch_span_processor.rb in opentelemetry-sdk-0.4.0 vs lib/opentelemetry/sdk/trace/export/batch_span_processor.rb in opentelemetry-sdk-0.5.0
- old
+ new
@@ -20,39 +20,32 @@
# max_export_batch_size.
#
# If the queue gets half full a preemptive notification is sent to the
# worker thread that exports the spans to wake up and start a new
# export cycle.
- #
- # max_export_attempts attempts are made to export each batch, while
- # export fails with {FAILED_RETRYABLE}, backing off linearly in 100ms
- # increments.
class BatchSpanProcessor
EXPORTER_TIMEOUT_MILLIS = 30_000
SCHEDULE_DELAY_MILLIS = 5_000
MAX_QUEUE_SIZE = 2048
MAX_EXPORT_BATCH_SIZE = 512
- MAX_EXPORT_ATTEMPTS = 5
- private_constant(:SCHEDULE_DELAY_MILLIS, :MAX_QUEUE_SIZE, :MAX_EXPORT_BATCH_SIZE, :MAX_EXPORT_ATTEMPTS)
+ private_constant(:SCHEDULE_DELAY_MILLIS, :MAX_QUEUE_SIZE, :MAX_EXPORT_BATCH_SIZE)
def initialize(exporter:,
exporter_timeout_millis: EXPORTER_TIMEOUT_MILLIS,
schedule_delay_millis: SCHEDULE_DELAY_MILLIS,
max_queue_size: MAX_QUEUE_SIZE,
- max_export_batch_size: MAX_EXPORT_BATCH_SIZE,
- max_export_attempts: MAX_EXPORT_ATTEMPTS)
+ max_export_batch_size: MAX_EXPORT_BATCH_SIZE)
raise ArgumentError if max_export_batch_size > max_queue_size
@exporter = exporter
@exporter_timeout_seconds = exporter_timeout_millis / 1000.0
@mutex = Mutex.new
@condition = ConditionVariable.new
@keep_running = true
@delay_seconds = schedule_delay_millis / 1000.0
@max_queue_size = max_queue_size
@batch_size = max_export_batch_size
- @export_attempts = max_export_attempts
@spans = []
@thread = Thread.new { work }
end
# does nothing for this processor
@@ -119,23 +112,17 @@
export_batch(batch)
end
end
def export_batch(batch)
- result_code = nil
- @export_attempts.times do |attempts|
- result_code = export_with_timeout(batch)
- break unless result_code == FAILED_RETRYABLE
-
- sleep(0.1 * attempts)
- end
+ result_code = export_with_timeout(batch)
report_result(result_code, batch)
end
def export_with_timeout(batch)
Timeout.timeout(@exporter_timeout_seconds) { @exporter.export(batch) }
rescue Timeout::Error
- FAILED_NOT_RETRYABLE
+ FAILURE
end
def report_result(result_code, batch)
OpenTelemetry.logger.error("Unable to export #{batch.size} spans") unless result_code == SUCCESS
end