Skip to content

Commit

Permalink
Analytics: don't spam warning when there is an HTTP connection problem (
Browse files Browse the repository at this point in the history
#1564)

* Improve analytics error messages

* Only log analytics failure once
  • Loading branch information
emilk authored Mar 13, 2023
1 parent 4b4f76a commit b88df11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions crates/re_analytics/src/pipeline_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ fn realtime_pipeline(
}

if let Err(err) = flush_events(session_file, &analytics_id, &session_id, sink) {
warn!(%err, %analytics_id, %session_id, "couldn't flush analytics data file");
re_log::debug_once!("couldn't flush analytics data file: {err}");
// We couldn't flush the session file: keep it intact so that we can retry later.
return;
}

if let Err(err) = session_file.set_len(0) {
warn!(%err, %analytics_id, %session_id, "couldn't truncate analytics data file");
re_log::warn_once!("couldn't truncate analytics data file: {err}");
// We couldn't truncate the session file: we'll have to keep it intact for now, which
// will result in duplicated data that we'll be able to deduplicate at query time.
return;
Expand All @@ -214,7 +214,7 @@ fn realtime_pipeline(
// We couldn't reset the session file... That one is a bit messy and will likely break
// analytics for the entire duration of this session, but that really _really_ should
// never happen.
warn!(%err, %analytics_id, %session_id, "couldn't seek into analytics data file");
re_log::warn_once!("couldn't seek into analytics data file: {err}");
}
};

Expand Down Expand Up @@ -288,7 +288,7 @@ fn flush_events(
) -> Result<(), SinkError> {
if let Err(err) = session_file.rewind() {
warn!(%err, %analytics_id, %session_id, "couldn't seek into analytics data file");
return Err(err.into());
return Err(SinkError::FileSeek(err));
}

let events = BufReader::new(&*session_file)
Expand Down
8 changes: 4 additions & 4 deletions crates/re_analytics/src/sink_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ struct Url(String);

#[derive(thiserror::Error, Debug)]
pub enum SinkError {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("File seek error: {0}")]
FileSeek(std::io::Error),

#[error(transparent)]
#[error("JSON: {0}")]
Serde(#[from] serde_json::Error),

#[error(transparent)]
#[error("HTTP transport: {0}")]
HttpTransport(Box<ureq::Transport>),

#[error("HTTP status {status_code} {status_text}: {body}")]
Expand Down

0 comments on commit b88df11

Please sign in to comment.