From aed49099492d9d21164aeb2f493cc6685797eb73 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 3 Oct 2023 11:40:51 +0200 Subject: [PATCH] add fetch and forward backend logs --- launch_demo.sh | 2 +- src/http/handlers/fetch.rs | 6 +++++- src/http/handlers/forward.rs | 6 +++++- src/http/handlers/mod.rs | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/launch_demo.sh b/launch_demo.sh index de9a6bb..406ed2e 100755 --- a/launch_demo.sh +++ b/launch_demo.sh @@ -23,7 +23,7 @@ elif [ "$1" = "fake_aws" ]; then RUST_LOG=info ./target/release/ds_proxy proxy --address "127.0.0.1:4444" --password-file <(echo -n "$PASSWORD") --salt "$SALT" --keyring-file "$KEYRING_FILE" --upstream-url "http://localhost:3333" --aws-access-key $ACCESS_KEY --aws-secret-key $SECRET_KEY --aws-region "eu-west-1" > "$DS_PROXY_LOG" 2>&1 & else echo 'launching ds_proxy listenning on 4444 binded on node server' - RUST_LOG=info ./target/release/ds_proxy proxy --address "127.0.0.1:4444" --password-file <(echo -n "$PASSWORD") --salt "$SALT" --keyring-file "$KEYRING_FILE" --upstream-url "http://localhost:3333" > "$DS_PROXY_LOG" 2>&1 & + RUST_LOG=info,ds_proxy::http::handlers::fetch=trace,ds_proxy::http::handlers::forward=trace ./target/release/ds_proxy proxy --address "127.0.0.1:4444" --password-file <(echo -n "$PASSWORD") --salt "$SALT" --keyring-file "$KEYRING_FILE" --upstream-url "http://localhost:3333" > "$DS_PROXY_LOG" 2>&1 & fi echo 'launching fake backend storage with node listenning on 3333' diff --git a/src/http/handlers/fetch.rs b/src/http/handlers/fetch.rs index 0483071..218d132 100644 --- a/src/http/handlers/fetch.rs +++ b/src/http/handlers/fetch.rs @@ -17,8 +17,10 @@ pub async fn fetch( return not_found(); } + let get_url = get_url.unwrap(); + let mut fetch_req = client - .request_from(get_url.unwrap(), req.head()) + .request_from(get_url.clone(), req.head()) .force_close(); let raw_range = req @@ -52,6 +54,8 @@ pub async fn fetch( } })?; + trace!("backend response for GET {:?} : {:?}", get_url, res); + if res.status().is_client_error() || res.status().is_server_error() { error!("fetch status error {:?} {:?}", req, res); } diff --git a/src/http/handlers/forward.rs b/src/http/handlers/forward.rs index 3976939..b0f6048 100644 --- a/src/http/handlers/forward.rs +++ b/src/http/handlers/forward.rs @@ -37,8 +37,10 @@ pub async fn forward( return not_found(); } + let put_url = put_url.unwrap(); + let mut forwarded_req = client - .request_from(put_url.unwrap(), req.head()) + .request_from(put_url.clone(), req.head()) .force_close() .timeout(UPLOAD_TIMEOUT); @@ -104,6 +106,8 @@ pub async fn forward( actix_web::error::ErrorBadGateway(e) })?; + trace!("backend response for PUT {:?} : {:?}", put_url, res); + if res.status().is_client_error() || res.status().is_server_error() { error!("forward status error {:?} {:?}", req, res); } diff --git a/src/http/handlers/mod.rs b/src/http/handlers/mod.rs index e290c75..adcdf89 100644 --- a/src/http/handlers/mod.rs +++ b/src/http/handlers/mod.rs @@ -21,7 +21,7 @@ use actix_web::{web, Error, HttpRequest, HttpResponse}; use awc::Client; use futures::TryStreamExt; use futures_core::stream::Stream; -use log::error; +use log::{error, trace}; pub static FETCH_RESPONSE_HEADERS_TO_REMOVE: [header::HeaderName; 3] = [ // Connection settings (keepalived) must not be resend