diff --git a/src/common/src/metrics.rs b/src/common/src/metrics.rs index 84947bdb14d34..bddd4447a7098 100644 --- a/src/common/src/metrics.rs +++ b/src/common/src/metrics.rs @@ -49,11 +49,14 @@ impl Atomic for TrAdderAtomic { pub type TrAdderGauge = GenericGauge; -pub struct CustomLayer { +/// [`MetricsLayer`] is a struct used for monitoring the frequency of certain specific logs and +/// counting them using Prometheus metrics. Currently, it is used to monitor the frequency of retry +/// occurrences of aws sdk. +pub struct MetricsLayer { pub aws_sdk_retry_counts: GenericCounter, } -impl Layer for CustomLayer +impl Layer for MetricsLayer where S: Subscriber + for<'a> LookupSpan<'a>, { @@ -61,12 +64,11 @@ where // Currently one retry will only generate one debug log, // so we can monitor the number of retry only through the metadata target. // Refer to - self.aws_sdk_retry_counts.inc(); } } -impl CustomLayer { +impl MetricsLayer { pub fn new(registry: Registry) -> Self { let aws_sdk_retry_counts = register_int_counter_with_registry!( "aws_sdk_retry_counts", diff --git a/src/utils/runtime/src/lib.rs b/src/utils/runtime/src/lib.rs index f5b60605244d4..1716ac98df4f5 100644 --- a/src/utils/runtime/src/lib.rs +++ b/src/utils/runtime/src/lib.rs @@ -21,7 +21,7 @@ use std::path::PathBuf; use std::time::Duration; use futures::Future; -use risingwave_common::metrics::CustomLayer; +use risingwave_common::metrics::MetricsLayer; use tracing::Level; use tracing_subscriber::filter::{Directive, Targets}; use tracing_subscriber::layer::SubscriberExt; @@ -282,7 +282,7 @@ pub fn init_risingwave_logger(settings: LoggerSettings, registry: prometheus::Re let filter = filter::Targets::new().with_target("aws_smithy_client::retry", Level::DEBUG); - layers.push(Box::new(CustomLayer::new(registry).with_filter(filter))); + layers.push(Box::new(MetricsLayer::new(registry).with_filter(filter))); tracing_subscriber::registry().with(layers).init(); // TODO: add file-appender tracing subscriber in the future