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

fix(telemetry): not send report if cluster is in test env #20180

Merged
merged 9 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
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
23 changes: 15 additions & 8 deletions src/common/src/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,27 @@ pub const TELEMETRY_CLUSTER_TYPE_HOSTED: &str = "hosted"; // hosted on RisingWav
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";
const TELEMETRY_CLUSTER_TYPE_TEST: &str = "test";

pub use risingwave_telemetry_event::get_telemetry_risingwave_cloud_uuid;

pub fn telemetry_cluster_type_from_env_var() -> PbTelemetryClusterType {
pub fn telemetry_cluster_type_from_env_var() -> TelemetryResult<PbTelemetryClusterType> {
let cluster_type = match env::var(TELEMETRY_CLUSTER_TYPE) {
Ok(cluster_type) => cluster_type,
Err(_) => return PbTelemetryClusterType::Unspecified,
Err(_) => return Ok(PbTelemetryClusterType::Unspecified),
};
match cluster_type.as_str() {
TELEMETRY_CLUSTER_TYPE_HOSTED => PbTelemetryClusterType::CloudHosted,
TELEMETRY_CLUSTER_TYPE_DOCKER_COMPOSE => PbTelemetryClusterType::DockerCompose,
TELEMETRY_CLUSTER_TYPE_KUBERNETES => PbTelemetryClusterType::Kubernetes,
TELEMETRY_CLUSTER_TYPE_SINGLE_NODE => PbTelemetryClusterType::SingleNode,
_ => PbTelemetryClusterType::Unspecified,
TELEMETRY_CLUSTER_TYPE_HOSTED => Ok(PbTelemetryClusterType::CloudHosted),
TELEMETRY_CLUSTER_TYPE_DOCKER_COMPOSE => Ok(PbTelemetryClusterType::DockerCompose),
TELEMETRY_CLUSTER_TYPE_KUBERNETES => Ok(PbTelemetryClusterType::Kubernetes),
TELEMETRY_CLUSTER_TYPE_SINGLE_NODE => Ok(PbTelemetryClusterType::SingleNode),

// block the report if the cluster is in test env
// but it only blocks the report from meta node, not other nodes
TELEMETRY_CLUSTER_TYPE_TEST => Err(TelemetryError::from(
"test cluster type should not send telemetry report",
)),
_ => Err(TelemetryError::from("invalid cluster type")),
}
}

Expand Down Expand Up @@ -156,7 +163,7 @@ pub fn report_scarf_enabled() -> bool {
telemetry_env_enabled()
&& !matches!(
telemetry_cluster_type_from_env_var(),
PbTelemetryClusterType::CloudHosted
Ok(PbTelemetryClusterType::CloudHosted)
)
}

Expand Down
3 changes: 2 additions & 1 deletion src/meta/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ impl TelemetryReportCreator for MetaReportCreator {
streaming_job_count,
meta_backend: MetaBackend::Sql,
job_desc: stream_job_desc,
cluster_type: telemetry_cluster_type_from_env_var(),
// it blocks the report if the cluster type is not valid or leak from test env
cluster_type: telemetry_cluster_type_from_env_var()?,
object_store_media_type: self.object_store_media_type,
})
}
Expand Down
Loading