From aa3ef79a861f47036af70fd292396f76c85d1a94 Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Tue, 28 Jun 2022 15:03:36 -0400 Subject: [PATCH] [internal] add observation metric for REAPI GetActionResult calls (#15967) Add an observation metric (histogram) for calls to Action Cache `GetActionResult` RPC. This will help with monitoring reads from remote cache. --- 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 2ebb57d48df..a2032635460 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, }