Skip to content

Commit

Permalink
Update S3 CRT client to to debug/warn on request failure based on sta…
Browse files Browse the repository at this point in the history
…tus code (#205)

* Update to debug/warn based on status code

Signed-off-by: Daniel Carl Jones <[email protected]>

* Appease fmt-check

Signed-off-by: Daniel Carl Jones <[email protected]>

* Appease clippy

Signed-off-by: Daniel Carl Jones <[email protected]>

---------

Signed-off-by: Daniel Carl Jones <[email protected]>
  • Loading branch information
dannycjones authored Apr 12, 2023
1 parent 03aafa1 commit 03c692a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions mountpoint-s3-client/src/s3_crt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,16 @@ impl S3CrtClient {

metrics::counter!("s3.meta_requests", 1, "op" => op);

let request_id = request_id.as_deref().unwrap_or("unknown");
let duration_us = start_time.elapsed().as_micros();
if request_result.is_err() {
debug!(
request_id = request_id.as_deref().unwrap_or("unknown"),
duration_us = start_time.elapsed().as_micros(),
?request_result,
"request failed"
);
let res_status_code = request_result.response_status;
if (200..=399).contains(&res_status_code) || res_status_code == 404 {
// Use debug level for less severe response codes.
debug!(request_id, duration_us, ?request_result, "request failed");
} else {
warn!(request_id, duration_us, ?request_result, "request failed");
}

// If it's not a real HTTP status, encode the CRT error instead
let error_status = if request_result.response_status >= 100 {
Expand All @@ -251,11 +254,7 @@ impl S3CrtClient {
};
metrics::counter!("s3.meta_request_failures", 1, "op" => op, "status" => format!("{error_status}"));
} else {
debug!(
request_id = request_id.as_deref().unwrap_or("unknown"),
duration_us = start_time.elapsed().as_micros(),
"request finished"
);
debug!(request_id, duration_us, "request finished");
}

let result = on_finish(request_result);
Expand Down

0 comments on commit 03c692a

Please sign in to comment.