Skip to content

Commit 146eecb

Browse files
authored
Merge pull request #11013 from Turbo87/github-logging
GitHub: Improve `tracing` usage
2 parents adea89b + 6c72a37 commit 146eecb

File tree

1 file changed

+11
-6
lines changed
  • crates/crates_io_github/src

1 file changed

+11
-6
lines changed

crates/crates_io_github/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,24 @@ impl RealGitHubClient {
5959
T: DeserializeOwned,
6060
{
6161
let url = format!("https://api.github.com{url}");
62-
info!("GITHUB HTTP: {url}");
62+
info!("GitHub request: GET {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)