Skip to content

Commit

Permalink
feat: adress comments
Browse files Browse the repository at this point in the history
  • Loading branch information
karlem committed Jul 19, 2024
1 parent 378d72c commit cfbeab6
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 150 deletions.
4 changes: 2 additions & 2 deletions fendermint/app/settings/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::Deserialize;
use serde_with::{serde_as, DurationSeconds};
use std::time::Duration;

use ipc_observability::traces_settings::TracesSettings;
use ipc_observability::config::TracingSettings;

use crate::{IsHumanReadable, MetricsSettings, SocketAddress};

Expand All @@ -21,7 +21,7 @@ pub struct EthSettings {
pub gas: GasOpt,
pub max_nonce_gap: u64,
pub metrics: MetricsSettings,
pub tracing: TracesSettings,
pub tracing: TracingSettings,
}

#[serde_as]
Expand Down
4 changes: 2 additions & 2 deletions fendermint/app/settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use fendermint_vm_topdown::BlockHeight;
use self::eth::EthSettings;
use self::fvm::FvmSettings;
use self::resolver::ResolverSettings;
use ipc_observability::traces_settings::TracesSettings;
use ipc_observability::config::TracingSettings;
use ipc_provider::config::deserialize::deserialize_eth_address_from_str;

pub mod eth;
Expand Down Expand Up @@ -287,7 +287,7 @@ pub struct Settings {
pub broadcast: BroadcastSettings,
pub ipc: IpcSettings,
pub testing: Option<TestingSettings>,
pub tracing: TracesSettings,
pub tracing: TracingSettings,
}

impl Settings {
Expand Down
4 changes: 2 additions & 2 deletions fendermint/app/src/cmd/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use fendermint_app_options::debug::{
DebugArgs, DebugCommands, DebugExportTopDownEventsArgs, DebugIpcCommands,
};
use fendermint_vm_topdown::proxy::IPCProviderProxy;
use ipc_observability::config::TracingSettings;
use ipc_observability::traces::set_global_tracing_subscriber;
use ipc_observability::traces_settings::TracesSettings;
use ipc_provider::{
config::subnet::{EVMSubnet, SubnetConfig},
IpcProvider,
Expand All @@ -25,7 +25,7 @@ cmd! {

cmd! {
DebugIpcCommands(self) {
let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default());
let _trace_file_guard = set_global_tracing_subscriber(&TracingSettings::default());

match self {
DebugIpcCommands::ExportTopDownEvents(args) => {
Expand Down
4 changes: 2 additions & 2 deletions fendermint/app/src/cmd/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use fendermint_vm_genesis::{
ipc, Account, Actor, ActorMeta, Collateral, Genesis, Multisig, PermissionMode, SignerAddr,
Validator, ValidatorKey,
};
use ipc_observability::config::TracingSettings;
use ipc_observability::traces::set_global_tracing_subscriber;
use ipc_observability::traces_settings::TracesSettings;

use crate::cmd;
use crate::options::genesis::*;
Expand All @@ -24,7 +24,7 @@ use super::key::read_public_key;

cmd! {
GenesisArgs(self) {
let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default());
let _trace_file_guard = set_global_tracing_subscriber(&TracingSettings::default());
let genesis_file = self.genesis_file.clone();

match &self.command {
Expand Down
4 changes: 2 additions & 2 deletions fendermint/app/src/cmd/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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::config::TracingSettings;
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;
Expand All @@ -23,7 +23,7 @@ use crate::{

cmd! {
KeyArgs(self) {
let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default());
let _trace_file_guard = set_global_tracing_subscriber(&TracingSettings::default());

match &self.command {
KeyCommands::Gen(args) => args.exec(()).await,
Expand Down
4 changes: 2 additions & 2 deletions fendermint/app/src/cmd/materializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ use fendermint_materializer::{
testnet::Testnet,
AccountId, TestnetId, TestnetName,
};
use ipc_observability::config::TracingSettings;
use ipc_observability::traces::set_global_tracing_subscriber;
use ipc_observability::traces_settings::TracesSettings;

use crate::cmd;

use super::key::{read_secret_key, read_secret_key_hex};

cmd! {
MaterializerArgs(self) {
let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default());
let _trace_file_guard = set_global_tracing_subscriber(&TracingSettings::default());

let data_dir = expand_tilde(&self.data_dir);
let dm = || DockerMaterializer::new(&data_dir, self.seed).map(|m| m.with_policy(DropPolicy::PERSISTENT));
Expand Down
4 changes: 2 additions & 2 deletions fendermint/app/src/cmd/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +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::config::TracingSettings;
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};
Expand All @@ -42,7 +42,7 @@ use super::key::read_secret_key;

cmd! {
RpcArgs(self) {
let _trace_file_guard = set_global_tracing_subscriber(&TracesSettings::default());
let _trace_file_guard = set_global_tracing_subscriber(&TracingSettings::default());

let client = FendermintClient::new_http(self.url.clone(), self.proxy_url.clone())?;
match self.command.clone() {
Expand Down
2 changes: 1 addition & 1 deletion ipc/observability/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub mod macros;
pub mod traces;
mod tracing_layers;
pub use lazy_static::lazy_static;
pub mod config;
pub mod serde;
pub mod traces_settings;

use std::fmt::Debug;
use tracing::{debug, error, info, trace, warn};
Expand Down
17 changes: 9 additions & 8 deletions ipc/observability/src/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use tracing::Level;
pub use tracing_appender::non_blocking;
pub use tracing_appender::non_blocking::WorkerGuard;
use tracing_appender::rolling::RollingFileAppender;
use tracing_subscriber::{fmt, fmt::Subscriber, layer::SubscriberExt, Layer, LogLevel};
use tracing_subscriber::{fmt, fmt::Subscriber, layer::SubscriberExt, Layer};

use crate::traces_settings::{FileLayerSettings, TracesSettings};
use crate::config::{FileLayerSettings, LogLevel, TracingSettings};
use crate::tracing_layers::DomainEventFilterLayer;
use tracing_subscriber::filter::EnvFilter;

//
pub fn create_temporary_subscriber() -> Subscriber {
Expand All @@ -21,10 +22,10 @@ pub fn create_temporary_subscriber() -> Subscriber {
.finish()
}

pub fn set_global_tracing_subscriber(config: &TracesSettings) -> Option<WorkerGuard> {
let console_filter = match config.console {
pub fn set_global_tracing_subscriber(config: &TracingSettings) -> Option<WorkerGuard> {
let console_filter = match &config.console {
Some(console_settings) => console_settings.level_to_filter(),
None => LogLevel::default().to_filter(),
None => EnvFilter::default(),
};

// log all traces to stderr (reserving stdout for any actual output such as from the CLI commands)
Expand All @@ -35,9 +36,9 @@ pub fn set_global_tracing_subscriber(config: &TracesSettings) -> Option<WorkerGu
.with_line_number(true)
.with_filter(console_filter);

let (file_layer, file_guard) = match config.file {
let (file_layer, file_guard) = match &config.file {
Some(file_settings) if file_settings.enabled => {
let (non_blocking, file_guard) = non_blocking(create_file_appender(&file_settings));
let (non_blocking, file_guard) = non_blocking(create_file_appender(file_settings));

let file_layer = fmt::layer()
.json()
Expand Down Expand Up @@ -94,7 +95,7 @@ fn create_file_appender(settings: &FileLayerSettings) -> RollingFileAppender {

if let Some(rotation_kind) = &settings.rotation {
println!("rotation kind: {:?}", rotation_kind);
appender = appender.rotation(rotation_kind.to_tracing_rotation());
appender = appender.rotation(rotation_kind.into());
};

appender
Expand Down
127 changes: 0 additions & 127 deletions ipc/observability/src/traces_settings.rs

This file was deleted.

0 comments on commit cfbeab6

Please sign in to comment.