From b1441981926b1b87e78755a758dfd260df66f649 Mon Sep 17 00:00:00 2001 From: phil Date: Wed, 11 Mar 2026 14:36:50 -0400 Subject: [PATCH] track how many requests host-throttling --- .gitignore | 2 ++ src/http.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index d9f9ebe..9cd9d99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target /lightrail.db /local + +/lr2.db diff --git a/src/http.rs b/src/http.rs index 97726f1..61d10f1 100644 --- a/src/http.rs +++ b/src/http.rs @@ -94,7 +94,9 @@ impl HttpClient for ThrottledClient { if let Some(host) = parts.uri.host() { let limiter = self.shared.get_or_create_limiter(host); while limiter.check().is_err() { + metrics::gauge!("lightrail_http_host_thorottling").increment(1); tokio::time::sleep(self.shared.token_interval).await; + metrics::gauge!("lightrail_http_host_thorottling").decrement(1); } } @@ -126,7 +128,9 @@ impl HttpClientExt for ThrottledClient { if let Some(host) = parts.uri.host() { let limiter = self.shared.get_or_create_limiter(host); while limiter.check().is_err() { + metrics::gauge!("lightrail_http_host_thorottling").increment(1); tokio::time::sleep(self.shared.token_interval).await; + metrics::gauge!("lightrail_http_host_thorottling").decrement(1); } } self.inner @@ -146,7 +150,9 @@ impl HttpClientExt for ThrottledClient { if let Some(host) = parts.uri.host() { let limiter = self.shared.get_or_create_limiter(host); while limiter.check().is_err() { + metrics::gauge!("lightrail_http_host_thorottling").increment(1); tokio::time::sleep(self.shared.token_interval).await; + metrics::gauge!("lightrail_http_host_thorottling").decrement(1); } } self.inner.send_http_bidirectional(parts, body).await -- 2.51.2