Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Emit number of currently blocked hosts #1295

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading