feat: add db.commit metric (#1188)

This commit is contained in:
Bjerg
2023-02-06 12:30:49 +01:00
committed by GitHub
parent 0f5a6b721c
commit a40745bab9
3 changed files with 11 additions and 2 deletions

2
Cargo.lock generated
View File

@ -4103,6 +4103,7 @@ dependencies = [
"futures",
"heapless",
"iai",
"metrics",
"modular-bitfield",
"page_size",
"parity-scale-codec",
@ -4707,6 +4708,7 @@ dependencies = [
"reth-eth-wire",
"reth-executor",
"reth-interfaces",
"reth-metrics-derive",
"reth-primitives",
"reth-provider",
"reth-rlp",

View File

@ -29,6 +29,9 @@ secp256k1 = { version = "0.24.2", default-features = false, features = [
], optional = true }
modular-bitfield = "0.11.2"
# metrics
metrics = "0.20.1"
# misc
bytes = "1.2.1"
page_size = "0.4.2"

View File

@ -7,8 +7,9 @@ use crate::{
transaction::{DbTx, DbTxGAT, DbTxMut, DbTxMutGAT},
Error,
};
use metrics::histogram;
use reth_libmdbx::{EnvironmentKind, Transaction, TransactionKind, WriteFlags, RW};
use std::marker::PhantomData;
use std::{marker::PhantomData, time::Instant};
/// Wrapper for the libmdbx transaction.
#[derive(Debug)]
@ -68,7 +69,10 @@ impl<'tx, K: TransactionKind, E: EnvironmentKind> DbTx<'tx> for Tx<'tx, K, E> {
}
fn commit(self) -> Result<bool, Error> {
self.inner.commit().map_err(|e| Error::Commit(e.into()))
let start = Instant::now();
let result = self.inner.commit().map_err(|e| Error::Commit(e.into()));
histogram!("tx.commit", start.elapsed());
result
}
fn get<T: Table>(&self, key: T::Key) -> Result<Option<<T as Table>::Value>, Error> {