@@ -64,6 +64,7 @@ use parking_lot::{Condvar, Mutex, MutexGuard};
6464use crate :: { manager:: CommittedRevision , root_store:: RootStore } ;
6565use crossbeam:: channel:: { self , Receiver , Sender } ;
6666
67+ use firewood_metrics:: firewood_increment;
6768use firewood_storage:: logger:: error;
6869
6970/// Error type for persistence operations.
@@ -385,6 +386,7 @@ impl PersistLoop {
385386 }
386387
387388 /// Persists the given revision and releases semaphore permits.
389+ #[ crate :: metrics( "persist.total" , "persist revision to storage" ) ]
388390 fn persist (
389391 & mut self ,
390392 revision : & CommittedRevision ,
@@ -444,9 +446,17 @@ impl PersistLoop {
444446 if let Some ( ref store) = self . shared . root_store
445447 && let ( Some ( hash) , Some ( addr) ) = ( revision. root_hash ( ) , revision. root_address ( ) )
446448 {
447- store
449+ let start = coarsetime:: Instant :: now ( ) ;
450+
451+ let result = store
448452 . add_root ( & hash, & addr)
449- . map_err ( |e| PersistError :: RootStore ( e. into ( ) ) ) ?;
453+ . map_err ( |e| PersistError :: RootStore ( e. into ( ) ) ) ;
454+
455+ let success = if result. is_err ( ) { "false" } else { "true" } ;
456+ firewood_increment ! ( crate :: registry:: PERSIST_ROOT_STORE , 1 , "success" => success) ;
457+ firewood_increment ! ( crate :: registry:: PERSIST_ROOT_STORE_MS , start. elapsed( ) . as_millis( ) , "success" => success) ;
458+
459+ result?;
450460 }
451461
452462 Ok ( ( ) )
0 commit comments