From 99fbd3b39daa1170be0bfa907ca9878acde88e03 Mon Sep 17 00:00:00 2001 From: Li Yazhou Date: Tue, 29 Oct 2024 19:19:55 +0800 Subject: [PATCH] add OPENDAL_RETRIES_COUNT --- src/common/storage/src/operator.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/common/storage/src/operator.rs b/src/common/storage/src/operator.rs index 6cf73e49d124..61ea0a3f89fb 100644 --- a/src/common/storage/src/operator.rs +++ b/src/common/storage/src/operator.rs @@ -16,11 +16,14 @@ use std::env; use std::io::Error; use std::io::ErrorKind; use std::io::Result; +use std::sync::LazyLock; use std::time::Duration; use anyhow::anyhow; use databend_common_base::base::GlobalInstance; use databend_common_base::http_client::GLOBAL_HTTP_CLIENT; +use databend_common_base::runtime::metrics::register_counter_family; +use databend_common_base::runtime::metrics::FamilyCounter; use databend_common_base::runtime::GlobalIORuntime; use databend_common_base::runtime::TrySpawn; use databend_common_exception::ErrorCode; @@ -58,6 +61,9 @@ use crate::metrics_layer::METRICS_LAYER; use crate::runtime_layer::RuntimeLayer; use crate::StorageConfig; +static METRIC_OPENDAL_RETRIES_COUNT: LazyLock>> = + LazyLock::new(|| register_counter_family("opendal_retries_count")); + /// init_operator will init an opendal operator based on storage config. pub fn init_operator(cfg: &StorageParams) -> Result { let op = match &cfg { @@ -389,6 +395,8 @@ pub struct DatabendRetryInterceptor; impl RetryInterceptor for DatabendRetryInterceptor { fn intercept(&self, err: &opendal::Error, dur: Duration) { + let labels = vec![("err", err.kind().to_string())]; + METRIC_OPENDAL_RETRIES_COUNT.get_or_create(&labels).inc(); warn!( target: "opendal::layers::retry", "will retry after {:.2}s because: {:?}",