Skip to content

Commit 0d80c66

Browse files
committed
Downgrade redirect follow log from warn to debug
Avoid noisy warnings when a synthetic 3xx is used for the redirect follow-up hop (context prefix redirect_follow_hop:). Made-with: Cursor
1 parent 4335669 commit 0d80c66

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

pingora-proxy/src/lib.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ use pingora_core::server::ShutdownWatch;
7676
use pingora_core::upstreams::peer::{HttpPeer, Peer};
7777
use pingora_error::{Error, ErrorSource, ErrorType::*, OrErr, Result};
7878

79+
/// Synthetic 3xx used for redirect follow-up is control flow, not a proxy failure.
80+
fn is_benign_upstream_retry_log(e: &Error) -> bool {
81+
matches!(&e.etype, HTTPStatus(code) if (300..400).contains(code))
82+
&& e.context
83+
.as_ref()
84+
.is_some_and(|c| c.as_str().starts_with("redirect_follow_hop:"))
85+
}
86+
7987
const TASK_BUFFER_SIZE: usize = 4;
8088

8189
mod proxy_cache;
@@ -977,13 +985,23 @@ where
977985
break;
978986
}
979987
// only log error that will be retried here, the final error will be logged below
980-
warn!(
981-
"Fail to proxy: {}, tries: {}, retry: {}, {}",
982-
proxy_error.as_ref().unwrap(),
983-
retries,
984-
retry,
985-
self.inner.request_summary(&session, &ctx)
986-
);
988+
if is_benign_upstream_retry_log(proxy_error.as_ref().unwrap()) {
989+
debug!(
990+
"Redirect follow: {}, tries: {}, retry: {}, {}",
991+
proxy_error.as_ref().unwrap(),
992+
retries,
993+
retry,
994+
self.inner.request_summary(&session, &ctx)
995+
);
996+
} else {
997+
warn!(
998+
"Fail to proxy: {}, tries: {}, retry: {}, {}",
999+
proxy_error.as_ref().unwrap(),
1000+
retries,
1001+
retry,
1002+
self.inner.request_summary(&session, &ctx)
1003+
);
1004+
}
9871005
}
9881006
None => {
9891007
proxy_error = None;

0 commit comments

Comments
 (0)