Skip to content

Commit 99fbd3b

Browse files
committed
add OPENDAL_RETRIES_COUNT
1 parent c44ea20 commit 99fbd3b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/common/storage/src/operator.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ use std::env;
1616
use std::io::Error;
1717
use std::io::ErrorKind;
1818
use std::io::Result;
19+
use std::sync::LazyLock;
1920
use std::time::Duration;
2021

2122
use anyhow::anyhow;
2223
use databend_common_base::base::GlobalInstance;
2324
use databend_common_base::http_client::GLOBAL_HTTP_CLIENT;
25+
use databend_common_base::runtime::metrics::register_counter_family;
26+
use databend_common_base::runtime::metrics::FamilyCounter;
2427
use databend_common_base::runtime::GlobalIORuntime;
2528
use databend_common_base::runtime::TrySpawn;
2629
use databend_common_exception::ErrorCode;
@@ -58,6 +61,9 @@ use crate::metrics_layer::METRICS_LAYER;
5861
use crate::runtime_layer::RuntimeLayer;
5962
use crate::StorageConfig;
6063

64+
static METRIC_OPENDAL_RETRIES_COUNT: LazyLock<FamilyCounter<Vec<(&'static str, String)>>> =
65+
LazyLock::new(|| register_counter_family("opendal_retries_count"));
66+
6167
/// init_operator will init an opendal operator based on storage config.
6268
pub fn init_operator(cfg: &StorageParams) -> Result<Operator> {
6369
let op = match &cfg {
@@ -389,6 +395,8 @@ pub struct DatabendRetryInterceptor;
389395

390396
impl RetryInterceptor for DatabendRetryInterceptor {
391397
fn intercept(&self, err: &opendal::Error, dur: Duration) {
398+
let labels = vec![("err", err.kind().to_string())];
399+
METRIC_OPENDAL_RETRIES_COUNT.get_or_create(&labels).inc();
392400
warn!(
393401
target: "opendal::layers::retry",
394402
"will retry after {:.2}s because: {:?}",

0 commit comments

Comments
 (0)