Skip to content

Commit

Permalink
feat: Emit number of currently blocked hosts (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim authored Sep 7, 2023
1 parent d69d0b0 commit afbb897
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/symbolicator-service/src/services/download/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl HostDenyList {
///
/// If that puts the host over the threshold, it is added
/// to the blocked servers.
fn register_failure(&self, host: String) {
fn register_failure(&self, source_name: &str, host: String) {
let current_ts = SystemTime::now();

tracing::trace!(
Expand Down Expand Up @@ -197,6 +197,7 @@ impl HostDenyList {
"Blocking host due to too many download failures"
);
self.blocked_hosts.insert(host, ());
metric!(gauge("service.download.blocked-hosts") = self.blocked_hosts.weighted_size(), "source" => source_name);
}
}

Expand Down Expand Up @@ -342,7 +343,8 @@ impl DownloadService {
}

if source_is_external {
self.host_deny_list.register_failure(host);
self.host_deny_list
.register_failure(&source_metric_key, host);
}
}

Expand Down Expand Up @@ -778,12 +780,12 @@ mod tests {
let deny_list = HostDenyList::from_config(&config);
let host = String::from("test");

deny_list.register_failure(host.clone());
deny_list.register_failure("test", host.clone());

// shouldn't be blocked after one failure
assert!(!deny_list.is_blocked(&host));

deny_list.register_failure(host.clone());
deny_list.register_failure("test", host.clone());

// should be blocked after two failures
assert!(deny_list.is_blocked(&host));
Expand Down

0 comments on commit afbb897

Please sign in to comment.