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

Queued events are ignored when flushing client #65

Open
ramosbugs opened this issue Dec 10, 2020 · 0 comments · May be fixed by #71
Open

Queued events are ignored when flushing client #65

ramosbugs opened this issue Dec 10, 2020 · 0 comments · May be fixed by #71

Comments

@ramosbugs
Copy link
Contributor

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();

ramosbugs added a commit to ramosbugs/libhoney-rust that referenced this issue Jan 9, 2021
ramosbugs added a commit to ramosbugs/libhoney-rust that referenced this issue Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant