aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-registry/src/downloader.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-23 23:52:13 +0900
committernsfisis <nsfisis@gmail.com>2026-02-23 23:52:13 +0900
commit2622fa3089d1df249276083d157e43b080a59100 (patch)
tree43bc31546fd3c81e13e5385cbf5cac493e045691 /crates/mozart-registry/src/downloader.rs
parentd6e0c6d34449224ac3687daf551a0acfd15cee32 (diff)
downloadphp-mozart-2622fa3089d1df249276083d157e43b080a59100.tar.gz
php-mozart-2622fa3089d1df249276083d157e43b080a59100.tar.zst
php-mozart-2622fa3089d1df249276083d157e43b080a59100.zip
feat(tracing): instrument network requests with tracing spans
Add #[tracing::instrument] and debug logs to all HTTP-calling functions in mozart-registry and mozart-vcs for request-level observability (URL, status code, cache hits, download size). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-registry/src/downloader.rs')
-rw-r--r--crates/mozart-registry/src/downloader.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/mozart-registry/src/downloader.rs b/crates/mozart-registry/src/downloader.rs
index 8bd99c7..6660188 100644
--- a/crates/mozart-registry/src/downloader.rs
+++ b/crates/mozart-registry/src/downloader.rs
@@ -79,6 +79,7 @@ impl DownloadProgress {
/// the `Content-Length` response header.
/// If `files_cache` is provided, the downloaded bytes are cached by URL; cache hits skip
/// the network request entirely.
+#[tracing::instrument(skip(expected_shasum, progress, files_cache))]
pub async fn download_dist(
url: &str,
expected_shasum: Option<&str>,
@@ -100,10 +101,12 @@ pub async fn download_dist(
hasher.update(&cached_bytes);
let computed = format!("{:x}", hasher.finalize());
if computed == shasum {
+ tracing::debug!("cache hit");
return Ok(cached_bytes);
}
// Checksum mismatch — discard cache, re-download
} else {
+ tracing::debug!("cache hit");
return Ok(cached_bytes);
}
}
@@ -112,6 +115,7 @@ pub async fn download_dist(
.user_agent(mozart_core::http::user_agent())
.build()?;
let response = client.get(url).send().await?;
+ tracing::debug!(status = %response.status(), "received response");
if !response.status().is_success() {
anyhow::bail!(
@@ -137,6 +141,8 @@ pub async fn download_dist(
response.bytes().await?.to_vec()
};
+ tracing::debug!(size = bytes.len(), "download complete");
+
// Verify SHA-1 checksum if provided
if let Some(shasum) = expected_shasum
&& !shasum.is_empty()