mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Integrate tracing (#6339)
Tracing Integration
- [reference](5bbf1859e9/projects/project-ideas.md (L297))
- [x] replace slog & log with tracing throughout the codebase
- [x] implement custom crit log
- [x] make relevant changes in the formatter
- [x] replace sloggers
- [x] re-write SSE logging components
cc: @macladson @eserilev
This commit is contained in:
@@ -12,7 +12,6 @@ use clap::ValueEnum;
|
||||
use cli::{Compact, Inspect};
|
||||
use environment::{Environment, RuntimeContext};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slog::{info, warn, Logger};
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
@@ -24,6 +23,7 @@ use store::{
|
||||
DBColumn, HotColdDB,
|
||||
};
|
||||
use strum::{EnumString, EnumVariantNames};
|
||||
use tracing::{info, warn};
|
||||
use types::{BeaconState, EthSpec, Slot};
|
||||
|
||||
fn parse_client_config<E: EthSpec>(
|
||||
@@ -49,7 +49,6 @@ fn parse_client_config<E: EthSpec>(
|
||||
pub fn display_db_version<E: EthSpec>(
|
||||
client_config: ClientConfig,
|
||||
runtime_context: &RuntimeContext<E>,
|
||||
log: Logger,
|
||||
) -> Result<(), Error> {
|
||||
let spec = runtime_context.eth2_config.spec.clone();
|
||||
let hot_path = client_config.get_db_path();
|
||||
@@ -67,16 +66,14 @@ pub fn display_db_version<E: EthSpec>(
|
||||
},
|
||||
client_config.store,
|
||||
spec,
|
||||
log.clone(),
|
||||
)?;
|
||||
|
||||
info!(log, "Database version: {}", version.as_u64());
|
||||
info!(version = version.as_u64(), "Database");
|
||||
|
||||
if version != CURRENT_SCHEMA_VERSION {
|
||||
info!(
|
||||
log,
|
||||
"Latest schema version: {}",
|
||||
CURRENT_SCHEMA_VERSION.as_u64(),
|
||||
current_schema_version = CURRENT_SCHEMA_VERSION.as_u64(),
|
||||
"Latest schema"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -260,7 +257,6 @@ fn parse_compact_config(compact_config: &Compact) -> Result<CompactConfig, Strin
|
||||
pub fn compact_db<E: EthSpec>(
|
||||
compact_config: CompactConfig,
|
||||
client_config: ClientConfig,
|
||||
log: Logger,
|
||||
) -> Result<(), Error> {
|
||||
let hot_path = client_config.get_db_path();
|
||||
let cold_path = client_config.get_freezer_db_path();
|
||||
@@ -284,10 +280,9 @@ pub fn compact_db<E: EthSpec>(
|
||||
)
|
||||
};
|
||||
info!(
|
||||
log,
|
||||
"Compacting database";
|
||||
"db" => db_name,
|
||||
"column" => ?column
|
||||
db = db_name,
|
||||
column = ?column,
|
||||
"Compacting database"
|
||||
);
|
||||
sub_db.compact_column(column)?;
|
||||
Ok(())
|
||||
@@ -308,7 +303,6 @@ pub fn migrate_db<E: EthSpec>(
|
||||
client_config: ClientConfig,
|
||||
mut genesis_state: BeaconState<E>,
|
||||
runtime_context: &RuntimeContext<E>,
|
||||
log: Logger,
|
||||
) -> Result<(), Error> {
|
||||
let spec = runtime_context.eth2_config.spec.clone();
|
||||
let hot_path = client_config.get_db_path();
|
||||
@@ -327,14 +321,12 @@ pub fn migrate_db<E: EthSpec>(
|
||||
},
|
||||
client_config.store.clone(),
|
||||
spec.clone(),
|
||||
log.clone(),
|
||||
)?;
|
||||
|
||||
info!(
|
||||
log,
|
||||
"Migrating database schema";
|
||||
"from" => from.as_u64(),
|
||||
"to" => to.as_u64(),
|
||||
from = from.as_u64(),
|
||||
to = to.as_u64(),
|
||||
"Migrating database schema"
|
||||
);
|
||||
|
||||
let genesis_state_root = genesis_state.canonical_root()?;
|
||||
@@ -343,14 +335,12 @@ pub fn migrate_db<E: EthSpec>(
|
||||
Some(genesis_state_root),
|
||||
from,
|
||||
to,
|
||||
log,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn prune_payloads<E: EthSpec>(
|
||||
client_config: ClientConfig,
|
||||
runtime_context: &RuntimeContext<E>,
|
||||
log: Logger,
|
||||
) -> Result<(), Error> {
|
||||
let spec = &runtime_context.eth2_config.spec;
|
||||
let hot_path = client_config.get_db_path();
|
||||
@@ -364,7 +354,6 @@ pub fn prune_payloads<E: EthSpec>(
|
||||
|_, _, _| Ok(()),
|
||||
client_config.store,
|
||||
spec.clone(),
|
||||
log,
|
||||
)?;
|
||||
|
||||
// If we're trigging a prune manually then ignore the check on the split's parent that bails
|
||||
@@ -376,7 +365,6 @@ pub fn prune_payloads<E: EthSpec>(
|
||||
pub fn prune_blobs<E: EthSpec>(
|
||||
client_config: ClientConfig,
|
||||
runtime_context: &RuntimeContext<E>,
|
||||
log: Logger,
|
||||
) -> Result<(), Error> {
|
||||
let spec = &runtime_context.eth2_config.spec;
|
||||
let hot_path = client_config.get_db_path();
|
||||
@@ -390,7 +378,6 @@ pub fn prune_blobs<E: EthSpec>(
|
||||
|_, _, _| Ok(()),
|
||||
client_config.store,
|
||||
spec.clone(),
|
||||
log,
|
||||
)?;
|
||||
|
||||
// If we're triggering a prune manually then ignore the check on `epochs_per_blob_prune` that
|
||||
@@ -413,7 +400,6 @@ pub fn prune_states<E: EthSpec>(
|
||||
prune_config: PruneStatesConfig,
|
||||
mut genesis_state: BeaconState<E>,
|
||||
runtime_context: &RuntimeContext<E>,
|
||||
log: Logger,
|
||||
) -> Result<(), String> {
|
||||
let spec = &runtime_context.eth2_config.spec;
|
||||
let hot_path = client_config.get_db_path();
|
||||
@@ -427,7 +413,6 @@ pub fn prune_states<E: EthSpec>(
|
||||
|_, _, _| Ok(()),
|
||||
client_config.store,
|
||||
spec.clone(),
|
||||
log.clone(),
|
||||
)
|
||||
.map_err(|e| format!("Unable to open database: {e:?}"))?;
|
||||
|
||||
@@ -447,20 +432,14 @@ pub fn prune_states<E: EthSpec>(
|
||||
// Check that the user has confirmed they want to proceed.
|
||||
if !prune_config.confirm {
|
||||
if db.get_anchor_info().full_state_pruning_enabled() {
|
||||
info!(log, "States have already been pruned");
|
||||
info!("States have already been pruned");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
info!(log, "Ready to prune states");
|
||||
warn!(
|
||||
log,
|
||||
"Pruning states is irreversible";
|
||||
);
|
||||
warn!(
|
||||
log,
|
||||
"Re-run this command with --confirm to commit to state deletion"
|
||||
);
|
||||
info!(log, "Nothing has been pruned on this run");
|
||||
info!("Ready to prune states");
|
||||
warn!("Pruning states is irreversible");
|
||||
warn!("Re-run this command with --confirm to commit to state deletion");
|
||||
info!("Nothing has been pruned on this run");
|
||||
return Err("Error: confirmation flag required".into());
|
||||
}
|
||||
|
||||
@@ -471,7 +450,7 @@ pub fn prune_states<E: EthSpec>(
|
||||
db.prune_historic_states(genesis_state_root, &genesis_state)
|
||||
.map_err(|e| format!("Failed to prune due to error: {e:?}"))?;
|
||||
|
||||
info!(log, "Historic states pruned successfully");
|
||||
info!("Historic states pruned successfully");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -483,7 +462,6 @@ pub fn run<E: EthSpec>(
|
||||
) -> Result<(), String> {
|
||||
let client_config = parse_client_config(cli_args, db_manager_config, &env)?;
|
||||
let context = env.core_context();
|
||||
let log = context.log().clone();
|
||||
let format_err = |e| format!("Fatal error: {:?}", e);
|
||||
|
||||
let get_genesis_state = || {
|
||||
@@ -498,7 +476,6 @@ pub fn run<E: EthSpec>(
|
||||
network_config.genesis_state::<E>(
|
||||
client_config.genesis_state_url.as_deref(),
|
||||
client_config.genesis_state_url_timeout,
|
||||
&log,
|
||||
),
|
||||
"get_genesis_state",
|
||||
)
|
||||
@@ -511,30 +488,29 @@ pub fn run<E: EthSpec>(
|
||||
cli::DatabaseManagerSubcommand::Migrate(migrate_config) => {
|
||||
let migrate_config = parse_migrate_config(migrate_config)?;
|
||||
let genesis_state = get_genesis_state()?;
|
||||
migrate_db(migrate_config, client_config, genesis_state, &context, log)
|
||||
.map_err(format_err)
|
||||
migrate_db(migrate_config, client_config, genesis_state, &context).map_err(format_err)
|
||||
}
|
||||
cli::DatabaseManagerSubcommand::Inspect(inspect_config) => {
|
||||
let inspect_config = parse_inspect_config(inspect_config)?;
|
||||
inspect_db::<E>(inspect_config, client_config)
|
||||
}
|
||||
cli::DatabaseManagerSubcommand::Version(_) => {
|
||||
display_db_version(client_config, &context, log).map_err(format_err)
|
||||
display_db_version(client_config, &context).map_err(format_err)
|
||||
}
|
||||
cli::DatabaseManagerSubcommand::PrunePayloads(_) => {
|
||||
prune_payloads(client_config, &context, log).map_err(format_err)
|
||||
prune_payloads(client_config, &context).map_err(format_err)
|
||||
}
|
||||
cli::DatabaseManagerSubcommand::PruneBlobs(_) => {
|
||||
prune_blobs(client_config, &context, log).map_err(format_err)
|
||||
prune_blobs(client_config, &context).map_err(format_err)
|
||||
}
|
||||
cli::DatabaseManagerSubcommand::PruneStates(prune_states_config) => {
|
||||
let prune_config = parse_prune_states_config(prune_states_config)?;
|
||||
let genesis_state = get_genesis_state()?;
|
||||
prune_states(client_config, prune_config, genesis_state, &context, log)
|
||||
prune_states(client_config, prune_config, genesis_state, &context)
|
||||
}
|
||||
cli::DatabaseManagerSubcommand::Compact(compact_config) => {
|
||||
let compact_config = parse_compact_config(compact_config)?;
|
||||
compact_db::<E>(compact_config, client_config, log).map_err(format_err)
|
||||
compact_db::<E>(compact_config, client_config).map_err(format_err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user