Skip to content

Queued events are ignored when flushing client #65

@ramosbugs

Description

@ramosbugs

The client flush method is implemented in terms of stopping and restarting the Transmission:

libhoney-rust/src/client.rs

Lines 122 to 133 in 2f7cdc8

/// flush closes and reopens the Transmission, ensuring events are sent without
/// waiting on the batch to be sent asyncronously. Generally, it is more efficient to
/// rely on asyncronous batches than to call Flush, but certain scenarios may require
/// Flush if asynchronous sends are not guaranteed to run (i.e. running in AWS Lambda)
/// Flush is not thread safe - use it only when you are sure that no other parts of
/// your program are calling Send
pub fn flush(&mut self) -> Result<()> {
info!("flushing libhoney client");
self.transmission.stop()?;
self.transmission.start();
Ok(())
}

Unfortunately, the stop event causes a break that breaks out of the loop and doesn't send any of the queued events:

if event.fields.contains_key("internal_stop_event") {
info!("got 'internal_stop_event' event");
break;
}

I think the code should probably jump to this line instead of breaking out of the loop:

let mut batches_sent = Vec::new();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions