Skip to content

Commit 7383265

Browse files
authored
[SVLS-8741] fix: Improve log messages for proxy flusher (#1123)
## Overview When the status code from the proxy flusher request is not 200 or 202, right now we log: ``` error!( "PROXY_FLUSHER | Request failed with status {status} to {url}: {body:?}" ); ``` and do not retry. This PR: 1. Adds retries for this type of failure, with 3 attempts in total 2. Changes the log to INFO level if it's not the final attempt. Keep ERROR level if it failed for the final attempt. ## Testing N/A
1 parent 06798fe commit 7383265

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

bottlecap/src/traces/proxy_flusher.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use thiserror::Error as ThisError;
55
use tokio::sync::OnceCell;
66
use tokio::{sync::Mutex, task::JoinSet};
77

8-
use tracing::{debug, error};
8+
use tracing::{debug, error, info};
99

1010
use crate::{
1111
FLUSH_RETRY_COUNT, config,
@@ -159,13 +159,22 @@ impl Flusher {
159159
"PROXY_FLUSHER | Successfully sent request in {} ms to {url}",
160160
elapsed.as_millis()
161161
);
162-
} else {
162+
return Ok(());
163+
} else if attempts >= FLUSH_RETRY_COUNT {
164+
// Final attempt. Log with error level and return error.
165+
let body_string = body.unwrap_or_default();
163166
error!(
164-
"PROXY_FLUSHER | Request failed with status {status} to {url}: {body:?}"
167+
"PROXY_FLUSHER | Request failed with status {status} to {url}: {body_string} after {attempts} attempts"
165168
);
169+
return Err(Box::new(FailedProxyRequestError {
170+
request,
171+
message: format!("Request failed with status {status}: {body_string}"),
172+
}));
166173
}
167-
168-
return Ok(());
174+
// Not the final attempt. Log with info level and retry.
175+
info!(
176+
"PROXY_FLUSHER | Request failed with status {status} to {url}: {body:?} (attempt {attempts}/{FLUSH_RETRY_COUNT})"
177+
);
169178
}
170179
Err(e) => {
171180
if attempts >= FLUSH_RETRY_COUNT {

0 commit comments

Comments
 (0)