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

feat(telemetry): record cloud hosted UUID #18019

Merged
merged 8 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/common/src/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 16 additions & 9 deletions src/common/src/telemetry/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/common/telemetry_event/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +35,13 @@ pub static TELEMETRY_TRACKING_ID: OnceLock<String> = 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<String> {
env::var(TELEMETRY_RISINGWAVE_CLOUD_UUID).ok()
}

pub fn report_event_common(
event_stage: PbTelemetryEventStage,
event_name: &str,
Expand Down
Loading