From 9d9af78e449958e1fe56fc7523853c2989df429a Mon Sep 17 00:00:00 2001 From: Liubov Dmitrieva Date: Sun, 4 Aug 2024 14:01:02 -0700 Subject: [PATCH] ods: publish number of uploaded bytes to CAS Summary: ods: publish number of uploaded bytes to CAS this is required for better tracking of amount of data uploaded Reviewed By: lmvasquezg Differential Revision: D60715769 fbshipit-source-id: 00eadc090cd9c4bf9607dee906d45865e0d64dd8 --- eden/mononoke/cas_client/client/dummy.rs | 4 ++++ eden/mononoke/cas_client/client/lib.rs | 2 ++ eden/mononoke/cas_client/scm_client/lib.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/eden/mononoke/cas_client/client/dummy.rs b/eden/mononoke/cas_client/client/dummy.rs index f7bcbac24009c..4834750b269c6 100644 --- a/eden/mononoke/cas_client/client/dummy.rs +++ b/eden/mononoke/cas_client/client/dummy.rs @@ -47,4 +47,8 @@ impl<'a> CasClient for DummyCasClient<'a> { ) -> Result, Error> { Ok(digests.to_vec()) } + + fn repo_name(&self) -> &str { + "dummy" + } } diff --git a/eden/mononoke/cas_client/client/lib.rs b/eden/mononoke/cas_client/client/lib.rs index 7c029f0ee6131..eac205985da51 100644 --- a/eden/mononoke/cas_client/client/lib.rs +++ b/eden/mononoke/cas_client/client/lib.rs @@ -39,4 +39,6 @@ pub trait CasClient: Sync + Send { &self, digests: &'a [MononokeDigest], ) -> Result, Error>; + /// Get the name of the repo this client is for. + fn repo_name(&self) -> &str; } diff --git a/eden/mononoke/cas_client/scm_client/lib.rs b/eden/mononoke/cas_client/scm_client/lib.rs index 2ef0ff5200219..e677a5ff86a7b 100644 --- a/eden/mononoke/cas_client/scm_client/lib.rs +++ b/eden/mononoke/cas_client/scm_client/lib.rs @@ -32,6 +32,7 @@ define_stats! { prefix = "mononoke.cas_client"; uploaded_manifests_count: timeseries(Rate, Sum), uploaded_files_count: timeseries(Rate, Sum), + uploaded_bytes: dynamic_histogram("{}.uploaded_bytes", (repo_name: String); 1_500_000, 0, 150_000_000, Average, Sum, Count; P 5; P 25; P 50; P 75; P 95; P 97; P 99), } const MAX_CONCURRENT_UPLOADS_TREES: usize = 200; @@ -94,6 +95,7 @@ where self.client.streaming_upload_blob(&digest, stream).await?; } STATS::uploaded_files_count.add_value(1); + STATS::uploaded_bytes.add_value(digest.1 as i64, (self.client.repo_name().to_string(),)); Ok(UploadOutcome::Uploaded(digest.1)) } @@ -254,6 +256,7 @@ where .await?; } STATS::uploaded_manifests_count.add_value(1); + STATS::uploaded_bytes.add_value(digest.1 as i64, (self.client.repo_name().to_string(),)); Ok(UploadOutcome::Uploaded(digest.1)) }