From 049fb625d3310adf19ecefc5a2c778bab48e588b Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Tue, 28 Jun 2022 16:20:38 -0400 Subject: [PATCH] [internal] add observation metric for REAPI GetActionResult calls (Cherry pick of #15967) (#15975) Add an observation metric (histogram) for calls to Action Cache `GetActionResult` RPC. This will help with monitoring reads from remote cache. [ci skip-build-wheels] --- src/rust/engine/process_execution/src/remote_cache.rs | 6 ++++++ src/rust/engine/workunit_store/src/metrics.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/rust/engine/process_execution/src/remote_cache.rs b/src/rust/engine/process_execution/src/remote_cache.rs index 8782f1520aa..8162813bb6f 100644 --- a/src/rust/engine/process_execution/src/remote_cache.rs +++ b/src/rust/engine/process_execution/src/remote_cache.rs @@ -521,6 +521,7 @@ async fn check_action_cache( |workunit| async move { workunit.increment_counter(Metric::RemoteCacheRequests, 1); + let start = Instant::now(); let client = action_cache_client.as_ref().clone(); let response = retry_call( client, @@ -580,6 +581,11 @@ async fn check_action_cache( }) .await; + workunit.record_observation( + ObservationMetric::RemoteCacheGetActionResultTimeMicros, + start.elapsed().as_micros() as u64, + ); + match response { Ok(response) => { workunit.increment_counter(Metric::RemoteCacheRequestsCached, 1); diff --git a/src/rust/engine/workunit_store/src/metrics.rs b/src/rust/engine/workunit_store/src/metrics.rs index b29a7e43e20..eb5e7f7b25b 100644 --- a/src/rust/engine/workunit_store/src/metrics.rs +++ b/src/rust/engine/workunit_store/src/metrics.rs @@ -80,4 +80,6 @@ pub enum ObservationMetric { /// The time saved (in milliseconds) thanks to a remote cache hit instead of running the process /// directly. RemoteCacheTimeSavedMs, + /// Remote cache timing (in microseconds) for GetActionResult calls. + RemoteCacheGetActionResultTimeMicros, }