diff --git a/fendermint/app/config/default.toml b/fendermint/app/config/default.toml index 548324eb4..004980995 100644 --- a/fendermint/app/config/default.toml +++ b/fendermint/app/config/default.toml @@ -63,6 +63,14 @@ host = "127.0.0.1" # The default port where the Prometheus exporter makes the metrics available. port = 9184 +[tracing] + +[tracing.console] +enabled = true + +[tracing.file] +enabled = false + [snapshots] # Enable the export and import of snapshots. enabled = false @@ -149,6 +157,14 @@ host = "127.0.0.1" port = 9185 +[eth.tracing] + +[eth.tracing.console] +enabled = true + +[eth.tracing.file] +enabled = false + # IPLD Resolver Configuration [resolver] # Time to wait between attempts to resolve a CID after an error. diff --git a/fendermint/app/src/cmd/debug.rs b/fendermint/app/src/cmd/debug.rs index 364fd36c1..015db3ead 100644 --- a/fendermint/app/src/cmd/debug.rs +++ b/fendermint/app/src/cmd/debug.rs @@ -6,6 +6,8 @@ use fendermint_app_options::debug::{ DebugArgs, DebugCommands, DebugExportTopDownEventsArgs, DebugIpcCommands, }; use fendermint_vm_topdown::proxy::IPCProviderProxy; +use ipc_observability::traces::set_global_tracing_subscriber; +use ipc_observability::traces_settings::TracesSettings; use ipc_provider::{ config::subnet::{EVMSubnet, SubnetConfig}, IpcProvider, @@ -23,9 +25,12 @@ cmd! { cmd! { DebugIpcCommands(self) { + let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default())?; + match self { - DebugIpcCommands::ExportTopDownEvents(args) => + DebugIpcCommands::ExportTopDownEvents(args) => { export_topdown_events(args).await + } } } } diff --git a/fendermint/app/src/cmd/eth.rs b/fendermint/app/src/cmd/eth.rs index b479c2dc8..96e588400 100644 --- a/fendermint/app/src/cmd/eth.rs +++ b/fendermint/app/src/cmd/eth.rs @@ -16,9 +16,10 @@ use crate::{ cmd! { EthArgs(self, settings: EthSettings) { + let _trace_file_guard = set_global_tracing_subscriber(&settings.tracing)?; + match self.command.clone() { EthCommands::Run { ws_url, http_url, connect_retry_delay } => { - let (client, driver) = HybridClient::new(http_url, ws_url, Duration::from_secs(connect_retry_delay)).context("failed to create HybridClient")?; let driver_handle = tokio::spawn(async move { driver.run().await }); @@ -35,8 +36,6 @@ cmd! { /// Run the Ethereum API facade. async fn run(settings: EthSettings, client: HybridClient) -> anyhow::Result<()> { - // TOOO kare - set up tracing - if settings.metrics.enabled { info!("metrics enabled"); diff --git a/fendermint/app/src/cmd/genesis.rs b/fendermint/app/src/cmd/genesis.rs index 183a89cb7..37e1bdea8 100644 --- a/fendermint/app/src/cmd/genesis.rs +++ b/fendermint/app/src/cmd/genesis.rs @@ -14,6 +14,8 @@ use fendermint_vm_genesis::{ ipc, Account, Actor, ActorMeta, Collateral, Genesis, Multisig, PermissionMode, SignerAddr, Validator, ValidatorKey, }; +use ipc_observability::traces::set_global_tracing_subscriber; +use ipc_observability::traces_settings::TracesSettings; use crate::cmd; use crate::options::genesis::*; @@ -22,7 +24,9 @@ use super::key::read_public_key; cmd! { GenesisArgs(self) { + let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default())?; let genesis_file = self.genesis_file.clone(); + match &self.command { GenesisCommands::New(args) => args.exec(genesis_file).await, GenesisCommands::AddAccount(args) => args.exec(genesis_file).await, diff --git a/fendermint/app/src/cmd/key.rs b/fendermint/app/src/cmd/key.rs index e5891ae0f..757426862 100644 --- a/fendermint/app/src/cmd/key.rs +++ b/fendermint/app/src/cmd/key.rs @@ -6,6 +6,8 @@ use fendermint_app_options::key::KeyShowPeerIdArgs; use fendermint_crypto::{from_b64, to_b64, PublicKey, SecretKey}; use fendermint_vm_actor_interface::eam::EthAddress; use fvm_shared::address::Address; +use ipc_observability::traces::set_global_tracing_subscriber; +use ipc_observability::traces_settings::TracesSettings; use rand_chacha::{rand_core::SeedableRng, ChaCha20Rng}; use serde_json::json; use std::path::Path; @@ -21,6 +23,8 @@ use crate::{ cmd! { KeyArgs(self) { + let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default())?; + match &self.command { KeyCommands::Gen(args) => args.exec(()).await, KeyCommands::IntoTendermint(args) => args.exec(()).await, diff --git a/fendermint/app/src/cmd/materializer.rs b/fendermint/app/src/cmd/materializer.rs index f55797d5d..5c236bc89 100644 --- a/fendermint/app/src/cmd/materializer.rs +++ b/fendermint/app/src/cmd/materializer.rs @@ -14,6 +14,8 @@ use fendermint_materializer::{ testnet::Testnet, AccountId, TestnetId, TestnetName, }; +use ipc_observability::traces::set_global_tracing_subscriber; +use ipc_observability::traces_settings::TracesSettings; use crate::cmd; @@ -21,6 +23,8 @@ use super::key::{read_secret_key, read_secret_key_hex}; cmd! { MaterializerArgs(self) { + let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default())?; + let data_dir = expand_tilde(&self.data_dir); let dm = || DockerMaterializer::new(&data_dir, self.seed).map(|m| m.with_policy(DropPolicy::PERSISTENT)); let lm = || dm().map(|m| LoggingMaterializer::new(m, "cli".to_string())); diff --git a/fendermint/app/src/cmd/rpc.rs b/fendermint/app/src/cmd/rpc.rs index a4012555b..a35256bfd 100644 --- a/fendermint/app/src/cmd/rpc.rs +++ b/fendermint/app/src/cmd/rpc.rs @@ -31,6 +31,8 @@ use tendermint_rpc::HttpClient; use fendermint_rpc::message::{GasParams, SignedMessageFactory}; use fendermint_rpc::{client::FendermintClient, query::QueryClient}; use fendermint_vm_actor_interface::eam::{self, CreateReturn, EthAddress}; +use ipc_observability::traces::set_global_tracing_subscriber; +use ipc_observability::traces_settings::TracesSettings; use crate::cmd; use crate::options::rpc::{BroadcastMode, FevmArgs, RpcFevmCommands, TransArgs}; @@ -40,6 +42,8 @@ use super::key::read_secret_key; cmd! { RpcArgs(self) { + let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default())?; + let client = FendermintClient::new_http(self.url.clone(), self.proxy_url.clone())?; match self.command.clone() { RpcCommands::Query { height, command } => { diff --git a/fendermint/app/src/cmd/run.rs b/fendermint/app/src/cmd/run.rs index 38f220c5f..92f8a2126 100644 --- a/fendermint/app/src/cmd/run.rs +++ b/fendermint/app/src/cmd/run.rs @@ -43,6 +43,8 @@ use ipc_observability::traces::set_global_tracing_subscriber; cmd! { RunArgs(self, settings) { + let _trace_file_guard = set_global_tracing_subscriber(&settings.tracing)?; + run(settings).await } } @@ -61,8 +63,6 @@ namespaces! { /// /// This method acts as our composition root. async fn run(settings: Settings) -> anyhow::Result<()> { - let _work_guard = set_global_tracing_subscriber(&settings.tracing)?; - let tendermint_rpc_url = settings.tendermint_rpc_url()?; tracing::info!("Connecting to Tendermint at {tendermint_rpc_url}"); diff --git a/ipc/observability/src/traces.rs b/ipc/observability/src/traces.rs index 6ba306c65..495db66ee 100644 --- a/ipc/observability/src/traces.rs +++ b/ipc/observability/src/traces.rs @@ -8,7 +8,7 @@ pub use tracing_appender::non_blocking::WorkerGuard; use tracing_appender::rolling::RollingFileAppender; use tracing_subscriber::{fmt, fmt::Subscriber, layer::SubscriberExt, Layer}; -use crate::traces_settings::{FileLayerSettings, TracesSettings}; +use crate::traces_settings::{FileLayerSettings, LogLevel, TracesSettings}; use crate::tracing_layers::DomainEventFilterLayer; use anyhow::Result; @@ -29,7 +29,14 @@ pub fn set_global_tracing_subscriber(config: &TracesSettings) -> Result Result, } impl Default for ConsoleLayerSettings { fn default() -> Self { ConsoleLayerSettings { enabled: true, - level: LogLevel::default(), + level: Some(LogLevel::default()), } } } #[serde_as] #[derive(Debug, Deserialize, Clone, Default)] - pub struct FileLayerSettings { pub enabled: bool, - pub level: LogLevel, + pub level: Option, pub directory: Option, pub max_log_files: Option, pub rotation: Option,