Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/common/storage/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +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;
Expand Down Expand Up @@ -58,6 +62,9 @@ use crate::runtime_layer::RuntimeLayer;
use crate::StorageConfig;
use crate::StorageHttpClient;

static METRIC_OPENDAL_RETRIES_COUNT: LazyLock<FamilyCounter<Vec<(&'static str, String)>>> =
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<Operator> {
let op = match &cfg {
Expand Down Expand Up @@ -397,6 +404,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: {:?}",
Expand Down
Loading