Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(metrics): add metric about opendal retries count #16724

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
8 changes: 8 additions & 0 deletions src/common/storage/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,6 +61,9 @@ use crate::metrics_layer::METRICS_LAYER;
use crate::runtime_layer::RuntimeLayer;
use crate::StorageConfig;

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 @@ -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: {:?}",
Expand Down
Loading