Skip to content

Commit

Permalink
[Traffic Control] Fix blocked reuqests metric
Browse files Browse the repository at this point in the history
  • Loading branch information
williampsmith committed Dec 11, 2024
1 parent 3cd7e2b commit 920519a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/sui-core/src/traffic_controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,20 @@ impl TrafficController {
pub async fn check(&self, client: &Option<IpAddr>, proxied_client: &Option<IpAddr>) -> bool {
let check_with_dry_run_maybe = |allowed| -> bool {
match (allowed, self.dry_run_mode()) {
// check succeeded
// request allowed
(true, _) => true,
// check failed while in dry-run mode
// request blocked while in dry-run mode
(false, true) => {
debug!("Dry run mode: Blocked request from client {:?}", client);
self.metrics.num_dry_run_blocked_requests.inc();
true
}
// check failed
(false, false) => false,
// request blocked
(false, false) => {
debug!("Blocked request from client {:?}", client);
self.metrics.requests_blocked_at_protocol.inc();
true
}
}
};

Expand Down Expand Up @@ -520,8 +524,7 @@ async fn handle_policy_response(
.is_none()
{
// Only increment the metric if the client was not already blocked
debug!("Blocking client: {:?}", client);
metrics.requests_blocked_at_protocol.inc();
debug!("Adding client {:?} to blocklist", client);
metrics.connection_ip_blocklist_len.inc();
}
}
Expand All @@ -535,8 +538,7 @@ async fn handle_policy_response(
.is_none()
{
// Only increment the metric if the client was not already blocked
debug!("Blocking proxied client: {:?}", client);
metrics.requests_blocked_at_protocol.inc();
debug!("Adding proxied client {:?} to blocklist", client);
metrics.proxy_ip_blocklist_len.inc();
}
}
Expand Down

0 comments on commit 920519a

Please sign in to comment.