Skip to content

Commit 74e6cfa

Browse files
author
Tom Dyas
authored
add counters for blob bytes uploaded/downloaded to/from CAS (#12471)
Add counters to track the number of bytes uploaded to, or downloaded from, a remote CAS for blobs. [ci skip-build-wheels]
1 parent 438a58e commit 74e6cfa

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/rust/engine/fs/store/src/remote.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use hashing::Digest;
1717
use log::Level;
1818
use remexec::content_addressable_storage_client::ContentAddressableStorageClient;
1919
use tonic::{Code, Request, Status};
20-
use workunit_store::{in_workunit, ObservationMetric, WorkunitMetadata};
20+
use workunit_store::{in_workunit, Metric, ObservationMetric, WorkunitMetadata};
2121

2222
#[derive(Clone)]
2323
pub struct ByteStore {
@@ -257,7 +257,13 @@ impl ByteStore {
257257
workunit_store,
258258
workunit_name,
259259
workunit_metadata,
260-
|_workunit| result_future,
260+
|workunit| async move {
261+
let result = result_future.await;
262+
if result.is_ok() {
263+
workunit.increment_counter(Metric::RemoteStoreBlobBytesUploaded, len as u64);
264+
}
265+
result
266+
},
261267
)
262268
.await
263269
} else {
@@ -366,7 +372,16 @@ impl ByteStore {
366372
workunit_store_handle.store,
367373
workunit_name,
368374
workunit_metadata,
369-
|_workunit| result_future,
375+
|workunit| async move {
376+
let result = result_future.await;
377+
if result.is_ok() {
378+
workunit.increment_counter(
379+
Metric::RemoteStoreBlobBytesDownloaded,
380+
digest.size_bytes as u64,
381+
);
382+
}
383+
result
384+
},
370385
)
371386
.await
372387
} else {

src/rust/engine/workunit_store/src/metrics.rs

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ pub enum Metric {
7575
RemoteExecutionSuccess,
7676
RemoteExecutionTimeouts,
7777
RemoteStoreMissingDigest,
78+
/// Total number of bytes of blobs downloaded from a remote CAS.
79+
RemoteStoreBlobBytesDownloaded,
80+
/// Total number of bytes of blobs uploaded to a remote CAS.
81+
RemoteStoreBlobBytesUploaded,
7882
}
7983

8084
impl Metric {

0 commit comments

Comments
 (0)