lib/opentelemetry/sdk/trace/export/batch_span_processor.rb in opentelemetry-sdk-1.1.0 vs lib/opentelemetry/sdk/trace/export/batch_span_processor.rb in opentelemetry-sdk-1.2.0

- old
+ new

@@ -28,14 +28,14 @@ class BatchSpanProcessor # rubocop:disable Metrics/ClassLength # Returns a new instance of the {BatchSpanProcessor}. # # @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 + # @param [Numeric] exporter_timeout the maximum allowed time to export data. + # 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. + # @param [Numeric] schedule_delay the delay interval between two consecutive exports. # Defaults to the value of the OTEL_BSP_SCHEDULE_DELAY environment # variable, if set, or 5,000 (5 seconds). # @param [Integer] max_queue_size the maximum queue size in spans. # Defaults to the value of the OTEL_BSP_MAX_QUEUE_SIZE environment # variable, if set, or 2048. @@ -72,11 +72,11 @@ # Does nothing for this processor def on_start(_span, _parent_context); end # Adds a span to the batch. Thread-safe; may block on lock. - def on_finish(span) # rubocop:disable Metrics/AbcSize + def on_finish(span) return unless span.context.trace_flags.sampled? lock do reset_on_fork n = spans.size + 1 - max_queue_size @@ -98,11 +98,11 @@ # the completed spans. # # @param [optional Numeric] timeout An optional timeout in seconds. # @return [Integer] SUCCESS if no error occurred, FAILURE if a # non-specific failure occurred, TIMEOUT if a timeout occurred. - def force_flush(timeout: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength + def force_flush(timeout: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength start_time = OpenTelemetry::Common::Utilities.timeout_timestamp snapshot = lock do reset_on_fork if @keep_running spans.shift(spans.size) end @@ -153,10 +153,10 @@ private attr_reader :spans, :max_queue_size, :batch_size - def work # rubocop:disable Metrics/AbcSize + def work loop do batch = lock do @condition.wait(@mutex, @delay_seconds) if spans.size < batch_size && @keep_running @condition.wait(@mutex, @delay_seconds) while spans.empty? && @keep_running return unless @keep_running