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

Logging SDK: Log warnings if user data is dropped #2630

Merged
merged 6 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion crates/re_log_types/src/data_table_batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ impl Drop for DataTableBatcherInner {
fn drop(&mut self) {
// Drop the receiving end of the table stream first and foremost, so that we don't block
// even if the output channel is bounded and currently full.
drop(self.rx_tables.take());
if let Some(rx_tables) = self.rx_tables.take() {
if !rx_tables.is_empty() {
re_log::warn!("Dropping data");
}
}

// NOTE: The command channel is private, if we're here, nothing is currently capable of
// sending data down the pipeline.
Expand Down
10 changes: 8 additions & 2 deletions crates/re_sdk/src/log_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ pub struct MemorySinkStorage {
pub(crate) rec_stream: Option<crate::RecordingStream>,
}

impl Drop for MemorySinkStorage {
fn drop(&mut self) {
if !self.msgs.read().is_empty() {
re_log::warn!("Dropping data in MemorySink");
}
}
}

impl MemorySinkStorage {
/// Write access to the inner array of [`LogMsg`].
#[inline]
Expand All @@ -134,9 +142,7 @@ impl MemorySinkStorage {
}
std::mem::take(&mut *self.msgs.write())
}
}

impl MemorySinkStorage {
/// Convert the stored messages into an in-memory Rerun log file.
#[inline]
pub fn concat_memory_sinks_as_bytes(
Expand Down
11 changes: 9 additions & 2 deletions crates/re_sdk/src/recording_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl RecordingStreamBuilder {
///
/// ## Example
///
/// ```no_run
/// ```
/// let rec_stream = re_sdk::RecordingStreamBuilder::new("my_app").buffered()?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
Expand All @@ -176,8 +176,15 @@ impl RecordingStreamBuilder {
///
/// ## Example
///
/// ```no_run
/// ```
/// # fn log_data(_: &re_sdk::RecordingStream) { }
///
/// let (rec_stream, storage) = re_sdk::RecordingStreamBuilder::new("my_app").memory()?;
///
/// log_data(&rec_stream);
///
/// let data = storage.take();
///
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
pub fn memory(
Expand Down