/// Collects spans from the proxy into `accum`.
///
/// Returns an error when the span sream has completed. An error may be
/// returned after accumulating spans.
Collects spans from the proxy into `accum`.
Returns an error when the span sream has completed. An error may be
returned after accumulating spans.
Collects spans from the proxy into ` accum ` . Returns an error when the span sream has completed . An error may be returned after accumulating spans .
async fn collect_batch(spans: &mut S, accum: &mut Vec<Span>) -> Result<(), SpanRxClosed> {
        loop {
            if accum.len() == Self::MAX_BATCH_SIZE {
                trace!(capacity = Self::MAX_BATCH_SIZE, "Batch capacity reached");
                return Ok(());
            }
            tokio::select! {
                biased;
                res = spans.next() => match res {
                    Some(span) => {
                        trace!(?span, "Adding to batch");
                        accum.push(span);
                    }
                    None => return Err(SpanRxClosed),
                },
                // Don't hold spans indefinitely. Return if we hit an idle
                // timeout and spans have been collected.
                _ = time::sleep(Self::MAX_BATCH_IDLE) => {
                    if !accum.is_empty() {
                        trace!(spans = accum.len(), "Flushing spans due to inactivitiy");
                        return Ok(());
                    }
                }
            }
        }
    }
async fn collect_batch ( spans : & mut S , accum : & mut Vec < Span > ) -> Result < ( ) , SpanRxClosed > { loop { if accum . len ( ) == Self :: MAX_BATCH_SIZE { trace ! ( capacity Self MAX_BATCH_SIZE " " ) ; return Ok ( ( ) ) ; } tokio :: select ! { biased res spans next ( ) match res { Some ( span ) { trace ( span " " ) accum push ( span ) } None return Err ( SpanRxClosed ) } // Don't hold spans indefinitely. Return if we hit an idle // timeout and spans have been collected. time sleep ( Self MAX_BATCH_IDLE ) { if accum is_empty ( ) { trace ( spans accum len ( ) " " ) return Ok ( ( ) ) } } } } }
Collects spans from the proxy into `accum`.
Collects spans from the proxy into ` accum ` .
spans
&mut S
accum
&mut Vec<Span>