Skip to content

Commit

Permalink
Merge pull request #93 from demarches-simplifiees/add_backend_logs
Browse files Browse the repository at this point in the history
add fetch and forward backend logs
  • Loading branch information
LeSim authored Oct 3, 2023
2 parents b7e1544 + aed4909 commit 198afc3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion launch_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 5 additions & 1 deletion src/http/handlers/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion src/http/handlers/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/http/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 198afc3

Please sign in to comment.