Skip to content

Commit 20e9bd6

Browse files
committed
GitHub: Add rate limit debug logging
1 parent a95bf1d commit 20e9bd6

File tree

1 file changed

+10
-5
lines changed
  • crates/crates_io_github/src

1 file changed

+10
-5
lines changed

crates/crates_io_github/src/lib.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,22 @@ impl RealGitHubClient {
6161
let url = format!("https://api.github.com{url}");
6262
info!("GITHUB HTTP: {url}");
6363

64-
self.client
64+
let response = self
65+
.client
6566
.get(&url)
6667
.header(header::ACCEPT, "application/vnd.github.v3+json")
6768
.header(header::AUTHORIZATION, auth)
6869
.header(header::USER_AGENT, "crates.io (https://crates.io)")
6970
.send()
7071
.await?
71-
.error_for_status()?
72-
.json()
73-
.await
74-
.map_err(Into::into)
72+
.error_for_status()?;
73+
74+
let headers = response.headers();
75+
let remaining = headers.get("x-ratelimit-remaining");
76+
let limit = headers.get("x-ratelimit-limit");
77+
debug!("GitHub rate limit remaining: {remaining:?}/{limit:?}");
78+
79+
response.json().await.map_err(Into::into)
7580
}
7681

7782
/// Sends a GET to GitHub using OAuth access token authentication

0 commit comments

Comments
 (0)