diff --git a/src/common/src/telemetry/mod.rs b/src/common/src/telemetry/mod.rs index 0e77adfb9802b..99cd13c109c27 100644 --- a/src/common/src/telemetry/mod.rs +++ b/src/common/src/telemetry/mod.rs @@ -39,6 +39,8 @@ pub const TELEMETRY_CLUSTER_TYPE_KUBERNETES: &str = "kubernetes"; pub const TELEMETRY_CLUSTER_TYPE_SINGLE_NODE: &str = "single-node"; pub const TELEMETRY_CLUSTER_TYPE_DOCKER_COMPOSE: &str = "docker-compose"; +pub use risingwave_telemetry_event::get_telemetry_risingwave_cloud_uuid; + pub fn telemetry_cluster_type_from_env_var() -> PbTelemetryClusterType { let cluster_type = match env::var(TELEMETRY_CLUSTER_TYPE) { Ok(cluster_type) => cluster_type, diff --git a/src/common/src/telemetry/report.rs b/src/common/src/telemetry/report.rs index 0d12491269ac9..9e8101c11367e 100644 --- a/src/common/src/telemetry/report.rs +++ b/src/common/src/telemetry/report.rs @@ -14,6 +14,7 @@ use std::sync::Arc; +use risingwave_telemetry_event::get_telemetry_risingwave_cloud_uuid; pub use risingwave_telemetry_event::{ current_timestamp, post_telemetry_report_pb, TELEMETRY_REPORT_URL, TELEMETRY_TRACKING_ID, }; @@ -65,15 +66,21 @@ where // fetch telemetry tracking_id from the meta node only at the beginning // 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(Some(id)) => id, - Ok(None) => { - tracing::info!("Telemetry is disabled"); - return; - } - Err(err) => { - tracing::error!("Telemetry failed to get tracking_id, err {}", err); - return; + let tracking_id = { + if let Some(cloud_uuid) = get_telemetry_risingwave_cloud_uuid() { + cloud_uuid + } else { + match info_fetcher.fetch_telemetry_info().await { + 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; + } + } } }; TELEMETRY_TRACKING_ID diff --git a/src/common/telemetry_event/src/lib.rs b/src/common/telemetry_event/src/lib.rs index 7a26164f9156d..140d14bc9b99e 100644 --- a/src/common/telemetry_event/src/lib.rs +++ b/src/common/telemetry_event/src/lib.rs @@ -16,6 +16,7 @@ /// Keep the stats report module in the common/ module mod util; +use std::env; use std::sync::OnceLock; use prost::Message; @@ -34,6 +35,13 @@ pub static TELEMETRY_TRACKING_ID: OnceLock = OnceLock::new(); pub const TELEMETRY_REPORT_URL: &str = "https://telemetry.risingwave.dev/api/v2/report"; +// the UUID of the RisingWave Cloud (if the cluster is hosted on RisingWave Cloud) +pub const TELEMETRY_RISINGWAVE_CLOUD_UUID: &str = "RISINGWAVE_CLOUD_UUID"; + +pub fn get_telemetry_risingwave_cloud_uuid() -> Option { + env::var(TELEMETRY_RISINGWAVE_CLOUD_UUID).ok() +} + pub fn report_event_common( event_stage: PbTelemetryEventStage, event_name: &str,