From 29a34870d7fb7f7a6bf9349ae637cb6923b21502 Mon Sep 17 00:00:00 2001 From: Andrea Campi Date: Fri, 31 Jan 2025 07:51:37 -0800 Subject: [PATCH] Cleanup: log SCS stats in a single place Summary: Very minor cleanup, but it will make it easier to understand what is going on. Reviewed By: clara-9 Differential Revision: D68950883 fbshipit-source-id: 971bd0a2aa23adcfe93a9e32ed42e01b36a3d1ac --- .../scs/scs_methods/src/source_control_impl.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eden/mononoke/scs/scs_methods/src/source_control_impl.rs b/eden/mononoke/scs/scs_methods/src/source_control_impl.rs index 996e8d316a42d..f121c2bf1abdc 100644 --- a/eden/mononoke/scs/scs_methods/src/source_control_impl.rs +++ b/eden/mononoke/scs/scs_methods/src/source_control_impl.rs @@ -710,6 +710,10 @@ fn log_result( STATS::total_request_internal_failure_permille.add_value(internal_failure * 1000); STATS::total_request_invalid_permille.add_value(invalid_request * 1000); STATS::total_request_overloaded.add_value(overloaded); + STATS::method_completion_time_ms.add_value( + stats.completion_time.as_millis_unchecked() as i64, + (method.to_string(),), + ); ctx.perf_counters().insert_perf_counters(&mut scuba); @@ -818,6 +822,11 @@ fn log_stream_complete( STATS::total_request_internal_failure_permille.add_value(internal_failure * 1000); STATS::total_request_invalid_permille.add_value(invalid_request * 1000); STATS::total_request_overloaded.add_value(overloaded); + // Only accounts for the time to start the stream, not the overall time. + STATS::method_completion_time_ms.add_value( + initial_future_stats.completion_time.as_millis_unchecked() as i64, + (method.to_string(),), + ); ctx.perf_counters().insert_perf_counters(&mut scuba); @@ -1001,8 +1010,6 @@ macro_rules! impl_thrift_methods { .on_cancel_with_data(|stats| log_cancelled(&ctx, stringify!($method_name), &stats, start_mem_stats.as_ref())) .await; log_result(ctx, "Request complete", stringify!($method_name), &stats, &res, start_mem_stats.as_ref()); - let method = stringify!($method_name).to_string(); - STATS::method_completion_time_ms.add_value(stats.completion_time.as_millis_unchecked() as i64, (method,)); res.map_err(Into::into) } }; @@ -1061,8 +1068,6 @@ macro_rules! impl_thrift_stream_methods { else { log_result(ctx.clone(), "Request complete", stringify!($method_name), &stats, &res, start_mem_stats.as_ref()); } - let method = stringify!($method_name).to_string(); - STATS::method_completion_time_ms.add_value(stats.completion_time.as_millis_unchecked() as i64, (method,)); let first_error = Arc::new(OnceLock::new()); let chunk_counter = AtomicU64::new(0); res.map_err(Into::into).map(move |(res, stream)| {