From 03c692abf6286aef990ec0dfd86ced3c445a9b65 Mon Sep 17 00:00:00 2001 From: Daniel Carl Jones Date: Wed, 12 Apr 2023 15:38:55 +0100 Subject: [PATCH] Update S3 CRT client to to debug/warn on request failure based on status code (#205) * Update to debug/warn based on status code Signed-off-by: Daniel Carl Jones * Appease fmt-check Signed-off-by: Daniel Carl Jones * Appease clippy Signed-off-by: Daniel Carl Jones --------- Signed-off-by: Daniel Carl Jones --- mountpoint-s3-client/src/s3_crt_client.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mountpoint-s3-client/src/s3_crt_client.rs b/mountpoint-s3-client/src/s3_crt_client.rs index f3b96cbc8..e088c6353 100644 --- a/mountpoint-s3-client/src/s3_crt_client.rs +++ b/mountpoint-s3-client/src/s3_crt_client.rs @@ -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 { @@ -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);