Add beacon chain persistence metric

This commit is contained in:
Paul Hauner 2019-08-11 18:28:57 +10:00
parent 42d300bdc3
commit 78db947e6e
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
2 changed files with 10 additions and 0 deletions

View File

@ -199,6 +199,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
/// Attempt to save this instance to `self.store`.
pub fn persist(&self) -> Result<(), Error> {
let timer = metrics::start_timer(&metrics::PERSIST_CHAIN);
let p: PersistedBeaconChain<T> = PersistedBeaconChain {
canonical_head: self.canonical_head.read().clone(),
op_pool: PersistedOperationPool::from_operation_pool(&self.op_pool),
@ -209,6 +211,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let key = Hash256::from_slice(&BEACON_CHAIN_DB_KEY.as_bytes());
self.store.put(&key, &p)?;
metrics::stop_timer(timer);
Ok(())
}

View File

@ -138,4 +138,10 @@ lazy_static! {
*/
pub static ref UPDATE_HEAD_TIMES: Result<Histogram> =
try_create_histogram("update_head_times", "Time taken to update the canonical head");
/*
* Persisting BeaconChain to disk
*/
pub static ref PERSIST_CHAIN: Result<Histogram> =
try_create_histogram("persist_chain", "Time taken to update the canonical head");
}