mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(metrics): fix missing metrics by installing prometheus before creating db env (#6659)
This commit is contained in:
@ -77,8 +77,13 @@ pub async fn launch_from_config<E: RethCliExt>(
|
||||
) -> eyre::Result<NodeHandle> {
|
||||
info!(target: "reth::cli", "reth {} starting", SHORT_VERSION);
|
||||
|
||||
// Register the prometheus recorder before creating the database,
|
||||
// because database init needs it to register metrics.
|
||||
config.install_prometheus_recorder()?;
|
||||
|
||||
let database = std::mem::take(&mut config.database);
|
||||
let db_instance = database.init_db(config.db.log_level, config.chain.chain)?;
|
||||
info!(target: "reth::cli", "Database opened");
|
||||
|
||||
match db_instance {
|
||||
DatabaseInstance::Real { db, data_dir } => {
|
||||
@ -121,7 +126,6 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit
|
||||
let config = self.load_config()?;
|
||||
|
||||
let prometheus_handle = self.config.install_prometheus_recorder()?;
|
||||
info!(target: "reth::cli", "Database opened");
|
||||
|
||||
let mut provider_factory =
|
||||
ProviderFactory::new(Arc::clone(&self.db), Arc::clone(&self.config.chain));
|
||||
|
||||
@ -14,6 +14,9 @@ const LARGE_VALUE_THRESHOLD_BYTES: usize = 4096;
|
||||
|
||||
/// Caches metric handles for database environment to make sure handles are not re-created
|
||||
/// on every operation.
|
||||
///
|
||||
/// Requires a metric recorder to be registered before creating an instance of this struct.
|
||||
/// Otherwise, metric recording will no-op.
|
||||
#[derive(Debug)]
|
||||
pub struct DatabaseEnvMetrics {
|
||||
/// Caches OperationMetrics handles for each table and operation tuple.
|
||||
|
||||
Reference in New Issue
Block a user