Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush full batches instead of silently dropping #245

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/sdk/trace/span_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl api::SpanProcessor for SimpleSpanProcessor {
}

/// A [`SpanProcessor`] that asynchronously buffers finished spans and reports
/// them at a preconfigured interval.
/// them when the batch is full or times out.
///
/// [`SpanProcessor`]: ../../../api/trace/span_processor/trait.SpanProcessor.html
#[derive(Debug)]
Expand Down Expand Up @@ -199,14 +199,17 @@ impl Future for BatchSpanProcessorWorker {
match futures::ready!(self.messages.poll_next_unpin(cx)) {
// Span has finished, add to buffer of pending spans.
Some(BatchMessage::ExportSpan(span)) => {
if self.buffer.len() < self.config.max_queue_size {
self.buffer.push(span);
self.buffer.push(span);

if self.buffer.len() >= self.config.max_export_batch_size {
self.export_spans();
}
}
// Span batch interval time reached, export current spans.
Some(BatchMessage::Tick) => self.export_spans(),
// Stream has terminated or processor is shutdown, return to finish execution.
None | Some(BatchMessage::Shutdown) => {
self.export_spans();
self.exporter.shutdown();
return Poll::Ready(());
}
Expand Down