@@ -16,11 +16,14 @@ use std::env;
1616use std:: io:: Error ;
1717use std:: io:: ErrorKind ;
1818use std:: io:: Result ;
19+ use std:: sync:: LazyLock ;
1920use std:: time:: Duration ;
2021
2122use anyhow:: anyhow;
2223use databend_common_base:: base:: GlobalInstance ;
2324use 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 ;
2427use databend_common_base:: runtime:: GlobalIORuntime ;
2528use databend_common_base:: runtime:: TrySpawn ;
2629use databend_common_exception:: ErrorCode ;
@@ -58,6 +61,9 @@ use crate::metrics_layer::METRICS_LAYER;
5861use crate :: runtime_layer:: RuntimeLayer ;
5962use 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.
6268pub fn init_operator ( cfg : & StorageParams ) -> Result < Operator > {
6369 let op = match & cfg {
@@ -389,6 +395,8 @@ pub struct DatabendRetryInterceptor;
389395
390396impl 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