Skip to content

Commit

Permalink
fix(common): fix telemetry err msg when disabled (#8880)
Browse files Browse the repository at this point in the history
  • Loading branch information
odysa authored Mar 31, 2023
1 parent a36e013 commit 07dbb8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 6 additions & 2 deletions src/common/src/telemetry/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use super::{

#[async_trait::async_trait]
pub trait TelemetryInfoFetcher {
async fn fetch_telemetry_info(&self) -> Result<String>;
async fn fetch_telemetry_info(&self) -> Result<Option<String>>;
}

pub trait TelemetryReportCreator {
Expand Down Expand Up @@ -63,7 +63,11 @@ where
// There is only one case tracking_id updated at the runtime ---- etcd data has been
// cleaned. There is no way that etcd has been cleaned but nodes are still running
let tracking_id = match info_fetcher.fetch_telemetry_info().await {
Ok(resp) => resp,
Ok(Some(id)) => id,
Ok(None) => {
tracing::info!("Telemetry is disabled");
return;
}
Err(err) => {
tracing::error!("Telemetry failed to get tracking_id, err {}", err);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/meta/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ impl<S: MetaStore> MetaTelemetryInfoFetcher<S> {

#[async_trait::async_trait]
impl<S: MetaStore> TelemetryInfoFetcher for MetaTelemetryInfoFetcher<S> {
async fn fetch_telemetry_info(&self) -> anyhow::Result<String> {
async fn fetch_telemetry_info(&self) -> anyhow::Result<Option<String>> {
let tracking_id = TrackingId::from_meta_store(&self.meta_store).await?;

Ok(tracking_id.into())
Ok(Some(tracking_id.into()))
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/rpc_client/src/meta_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,12 +1017,10 @@ impl HummockMetaClient for MetaClient {

#[async_trait]
impl TelemetryInfoFetcher for MetaClient {
async fn fetch_telemetry_info(&self) -> anyhow::Result<String> {
async fn fetch_telemetry_info(&self) -> anyhow::Result<Option<String>> {
let resp = self.get_telemetry_info().await?;
let tracking_id = resp
.get_tracking_id()
.map_err(|e| anyhow::format_err!("failed to get tracking_id {:?}", e))?;
Ok(tracking_id.to_string())
let tracking_id = resp.get_tracking_id().ok();
Ok(tracking_id.map(|id| id.to_owned()))
}
}

Expand Down

0 comments on commit 07dbb8a

Please sign in to comment.