diff --git a/crates/aptos-logger/src/aptos_logger.rs b/crates/aptos-logger/src/aptos_logger.rs index fccad69b2af44..9d6843e7a289a 100644 --- a/crates/aptos-logger/src/aptos_logger.rs +++ b/crates/aptos-logger/src/aptos_logger.rs @@ -13,7 +13,8 @@ use crate::{ sample, sample::SampleRate, telemetry_log_writer::{TelemetryLog, TelemetryLogWriter}, - Event, Filter, Key, Level, LevelFilter, Metadata, + Event, Filter, Key, Level, LevelFilter, Metadata, ERROR_LOG_COUNT, INFO_LOG_COUNT, + WARN_LOG_COUNT, }; use aptos_infallible::RwLock; use backtrace::Backtrace; @@ -604,6 +605,12 @@ impl LoggerService { match event { LoggerServiceEvent::LogEntry(entry) => { PROCESSED_STRUCT_LOG_COUNT.inc(); + match entry.metadata.level() { + Level::Error => ERROR_LOG_COUNT.inc(), + Level::Warn => WARN_LOG_COUNT.inc(), + Level::Info => INFO_LOG_COUNT.inc(), + _ => {}, + } if let Some(printer) = &mut self.printer { if self diff --git a/crates/aptos-logger/src/counters.rs b/crates/aptos-logger/src/counters.rs index eae4d8a8c15ac..0e0e530b98821 100644 --- a/crates/aptos-logger/src/counters.rs +++ b/crates/aptos-logger/src/counters.rs @@ -20,9 +20,13 @@ pub static PROCESSED_STRUCT_LOG_COUNT: Lazy = Lazy::new(|| { .unwrap() }); -/// Count of error!() logs +/// Counts of logs pub static ERROR_LOG_COUNT: Lazy = Lazy::new(|| register_int_counter!("aptos_error_log_count", "Count of error!() logs").unwrap()); +pub static WARN_LOG_COUNT: Lazy = + Lazy::new(|| register_int_counter!("aptos_warn_log_count", "Count of warn!() logs").unwrap()); +pub static INFO_LOG_COUNT: Lazy = + Lazy::new(|| register_int_counter!("aptos_info_log_count", "Count of info!() logs").unwrap()); /// Metric for when we fail to log during sending to the queue pub static STRUCT_LOG_QUEUE_ERROR_COUNT: Lazy = Lazy::new(|| { diff --git a/crates/aptos-logger/src/lib.rs b/crates/aptos-logger/src/lib.rs index 86dcfa5909317..26a5d0ad15ec0 100644 --- a/crates/aptos-logger/src/lib.rs +++ b/crates/aptos-logger/src/lib.rs @@ -169,4 +169,4 @@ pub use metadata::{Level, Metadata}; pub use security::SecurityEvent; mod counters; -pub use counters::ERROR_LOG_COUNT; +pub use counters::{ERROR_LOG_COUNT, INFO_LOG_COUNT, WARN_LOG_COUNT}; diff --git a/crates/aptos-logger/src/macros.rs b/crates/aptos-logger/src/macros.rs index f43c9d8406485..b79dc0fd82125 100644 --- a/crates/aptos-logger/src/macros.rs +++ b/crates/aptos-logger/src/macros.rs @@ -60,10 +60,6 @@ macro_rules! log { concat!(file!(), ':', line!()), ); - if METADATA.level() == $crate::Level::Error { - $crate::ERROR_LOG_COUNT.inc(); - } - if METADATA.enabled() { $crate::Event::dispatch( &METADATA,