mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add db.commit metric (#1188)
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -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",
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user