diff --git a/Cargo.lock b/Cargo.lock index 1014a1c..40fd616 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2711,6 +2711,7 @@ dependencies = [ "reqwest", "serde", "thiserror", + "tracing", ] [[package]] diff --git a/crates/pile-client/Cargo.toml b/crates/pile-client/Cargo.toml index a58a00e..e51e893 100644 --- a/crates/pile-client/Cargo.toml +++ b/crates/pile-client/Cargo.toml @@ -14,3 +14,4 @@ serde = { workspace = true } thiserror = { workspace = true } bytes = { workspace = true } axum = { workspace = true } +tracing = { workspace = true } diff --git a/crates/pile-client/src/lib.rs b/crates/pile-client/src/lib.rs index e5cc861..c91458a 100644 --- a/crates/pile-client/src/lib.rs +++ b/crates/pile-client/src/lib.rs @@ -2,6 +2,7 @@ use axum::{ Router, body::Body as AxumBody, extract::State, response::Response as AxumResponse, routing::any, }; +use tracing::{debug, warn}; use bytes::Bytes; use futures_core::Stream; use reqwest::{Client, StatusCode, header}; @@ -262,6 +263,7 @@ async fn proxy_handler( let method = req.method().clone(); let url = format!("{}{}{}", state.base_url, path, query_str); + debug!(method = %method, url, "proxying request"); let mut req_builder = state.client.request(method, &url); // Forward all request headers except hop-by-hop and Host. @@ -286,6 +288,7 @@ async fn proxy_handler( let upstream = match req_builder.send().await { Ok(r) => r, Err(e) => { + warn!(error = %e, "upstream request failed"); return AxumResponse::builder() .status(StatusCode::BAD_GATEWAY.as_u16()) .body(AxumBody::from(e.to_string())) @@ -294,6 +297,7 @@ async fn proxy_handler( }; let status = upstream.status().as_u16(); + debug!(status, "upstream response"); let resp_headers = upstream.headers().clone(); let mut builder = AxumResponse::builder().status(status);