@@ -16,10 +16,13 @@ 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 ;
24+ use databend_common_base:: runtime:: metrics:: register_counter_family;
25+ use databend_common_base:: runtime:: metrics:: FamilyCounter ;
2326use databend_common_base:: runtime:: GlobalIORuntime ;
2427use databend_common_base:: runtime:: TrySpawn ;
2528use databend_common_exception:: ErrorCode ;
@@ -58,6 +61,9 @@ use crate::runtime_layer::RuntimeLayer;
5861use crate :: StorageConfig ;
5962use crate :: StorageHttpClient ;
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 {
@@ -397,6 +403,8 @@ pub struct DatabendRetryInterceptor;
397403
398404impl RetryInterceptor for DatabendRetryInterceptor {
399405 fn intercept ( & self , err : & opendal:: Error , dur : Duration ) {
406+ let labels = vec ! [ ( "err" , err. kind( ) . to_string( ) ) ] ;
407+ METRIC_OPENDAL_RETRIES_COUNT . get_or_create ( & labels) . inc ( ) ;
400408 warn ! (
401409 target: "opendal::layers::retry" ,
402410 "will retry after {:.2}s because: {:?}" ,
0 commit comments