diff --git a/docker/docker-compose-distributed-etcd.yml b/docker/docker-compose-distributed-etcd.yml index aed8ccab0329a..9651d9d25e5f1 100644 --- a/docker/docker-compose-distributed-etcd.yml +++ b/docker/docker-compose-distributed-etcd.yml @@ -20,7 +20,7 @@ services: expose: - "6660" - "1260" - ports: [] + ports: [ ] depends_on: - meta-node-0 # - minio-0 @@ -62,7 +62,7 @@ services: expose: - "5688" - "1222" - ports: [] + ports: [ ] depends_on: - meta-node-0 # - minio-0 @@ -120,10 +120,10 @@ services: ports: - "2388:2388" - "2389:2389" - depends_on: [] + depends_on: [ ] volumes: - "etcd-0:/etcd-data" - environment: {} + environment: { } container_name: etcd-0 healthcheck: test: @@ -179,19 +179,19 @@ services: memory: 1G grafana-0: image: "grafana/grafana-oss:latest" - command: [] + command: [ ] expose: - "3001" ports: - "3001:3001" - depends_on: [] + depends_on: [ ] volumes: - "grafana-0:/var/lib/grafana" - "./grafana.ini:/etc/grafana/grafana.ini" - "./grafana-risedev-datasource.yml:/etc/grafana/provisioning/datasources/grafana-risedev-datasource.yml" - "./grafana-risedev-dashboard.yml:/etc/grafana/provisioning/dashboards/grafana-risedev-dashboard.yml" - "./dashboards:/dashboards" - environment: {} + environment: { } container_name: grafana-0 healthcheck: test: @@ -240,6 +240,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: meta-node-0 healthcheck: test: @@ -270,7 +271,7 @@ services: ports: - "9301:9301" - "9400:9400" - depends_on: [] + depends_on: [ ] volumes: - "minio-0:/data" entrypoint: " @@ -313,11 +314,11 @@ services: - "9500" ports: - "9500:9500" - depends_on: [] + depends_on: [ ] volumes: - "prometheus-0:/prometheus" - "./prometheus.yaml:/etc/prometheus/prometheus.yml" - environment: {} + environment: { } container_name: prometheus-0 healthcheck: test: @@ -355,10 +356,10 @@ services: - "9092:9092" - "9644:9644" - "8081:8081" - depends_on: [] + depends_on: [ ] volumes: - "message_queue:/var/lib/redpanda/data" - environment: {} + environment: { } container_name: message_queue healthcheck: test: curl -f localhost:9644/v1/status/ready diff --git a/docker/docker-compose-distributed.yml b/docker/docker-compose-distributed.yml index b43f5f1f1921f..37f584dbfe277 100644 --- a/docker/docker-compose-distributed.yml +++ b/docker/docker-compose-distributed.yml @@ -19,7 +19,7 @@ services: expose: - "6660" - "1260" - ports: [] + ports: [ ] depends_on: - meta-node-0 # - minio-0 @@ -61,7 +61,7 @@ services: expose: - "5688" - "1222" - ports: [] + ports: [ ] depends_on: - meta-node-0 # - minio-0 @@ -148,12 +148,12 @@ services: memory: 1G grafana-0: image: "grafana/grafana-oss:latest" - command: [] + command: [ ] expose: - "3001" ports: - "3001:3001" - depends_on: [] + depends_on: [ ] volumes: - "grafana-0:/var/lib/grafana" - "./grafana.ini:/etc/grafana/grafana.ini" @@ -210,6 +210,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: meta-node-0 healthcheck: test: @@ -240,7 +241,7 @@ services: ports: - "9301:9301" - "9400:9400" - depends_on: [] + depends_on: [ ] volumes: - "minio-0:/data" entrypoint: " @@ -283,7 +284,7 @@ services: - "9500" ports: - "9500:9500" - depends_on: [] + depends_on: [ ] volumes: - "prometheus-0:/prometheus" - "./prometheus.yaml:/etc/prometheus/prometheus.yml" @@ -325,7 +326,7 @@ services: - "9092:9092" - "9644:9644" - "8081:8081" - depends_on: [] + depends_on: [ ] volumes: - "message_queue:/var/lib/redpanda/data" environment: {} diff --git a/docker/docker-compose-etcd.yml b/docker/docker-compose-etcd.yml index fb1787a029f01..78e5c1c0a0a75 100644 --- a/docker/docker-compose-etcd.yml +++ b/docker/docker-compose-etcd.yml @@ -59,6 +59,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: @@ -110,10 +111,10 @@ services: ports: - "2388:2388" - "2389:2389" - depends_on: [] + depends_on: [ ] volumes: - "etcd-0:/etcd-data" - environment: {} + environment: { } container_name: etcd-0 healthcheck: test: @@ -129,19 +130,19 @@ services: grafana-0: image: "grafana/grafana-oss:latest" - command: [] + command: [ ] expose: - "3001" ports: - "3001:3001" - depends_on: [] + depends_on: [ ] volumes: - "grafana-0:/var/lib/grafana" - "./grafana.ini:/etc/grafana/grafana.ini" - "./grafana-risedev-datasource.yml:/etc/grafana/provisioning/datasources/grafana-risedev-datasource.yml" - "./grafana-risedev-dashboard.yml:/etc/grafana/provisioning/dashboards/grafana-risedev-dashboard.yml" - "./dashboards:/dashboards" - environment: {} + environment: { } container_name: grafana-0 healthcheck: test: @@ -167,7 +168,7 @@ services: ports: - "9301:9301" - "9400:9400" - depends_on: [] + depends_on: [ ] volumes: - "minio-0:/data" entrypoint: " @@ -211,11 +212,11 @@ services: - "9500" ports: - "9500:9500" - depends_on: [] + depends_on: [ ] volumes: - "prometheus-0:/prometheus" - "./prometheus.yaml:/etc/prometheus/prometheus.yml" - environment: {} + environment: { } container_name: prometheus-0 healthcheck: test: @@ -254,10 +255,10 @@ services: - "9092:9092" - "9644:9644" - "8081:8081" - depends_on: [] + depends_on: [ ] volumes: - "message_queue:/var/lib/redpanda/data" - environment: {} + environment: { } container_name: message_queue healthcheck: test: curl -f localhost:9644/v1/status/ready diff --git a/docker/docker-compose-with-azblob.yml b/docker/docker-compose-with-azblob.yml index 3269b2c815a82..711764b49bd44 100644 --- a/docker/docker-compose-with-azblob.yml +++ b/docker/docker-compose-with-azblob.yml @@ -58,6 +58,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: diff --git a/docker/docker-compose-with-gcs.yml b/docker/docker-compose-with-gcs.yml index 1de6b4ee6253d..e45e8851572e0 100644 --- a/docker/docker-compose-with-gcs.yml +++ b/docker/docker-compose-with-gcs.yml @@ -58,6 +58,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: diff --git a/docker/docker-compose-with-hdfs.yml b/docker/docker-compose-with-hdfs.yml index 974cf922e77b4..fc0fbb4067276 100644 --- a/docker/docker-compose-with-hdfs.yml +++ b/docker/docker-compose-with-hdfs.yml @@ -17,7 +17,7 @@ services: expose: - "6660" - "1260" - ports: [] + ports: [ ] depends_on: - meta-node-0 volumes: @@ -57,7 +57,7 @@ services: expose: - "5688" - "1222" - ports: [] + ports: [ ] depends_on: - meta-node-0 volumes: @@ -113,7 +113,7 @@ services: ports: - "2388:2388" - "2389:2389" - depends_on: [] + depends_on: [ ] volumes: - "etcd-0:/etcd-data" environment: @@ -171,19 +171,19 @@ services: memory: 1G grafana-0: image: "grafana/grafana-oss:latest" - command: [] + command: [ ] expose: - "3001" ports: - "3001:3001" - depends_on: [] + depends_on: [ ] volumes: - "grafana-0:/var/lib/grafana" - "./grafana.ini:/etc/grafana/grafana.ini" - "./grafana-risedev-datasource.yml:/etc/grafana/provisioning/datasources/grafana-risedev-datasource.yml" - "./grafana-risedev-dashboard.yml:/etc/grafana/provisioning/dashboards/grafana-risedev-dashboard.yml" - "./dashboards:/dashboards" - environment: {} + environment: { } container_name: grafana-0 healthcheck: test: @@ -231,6 +231,7 @@ services: - ":/opt/hadoop" environment: - HADOOP_HOME=/opt/hadoop/ + - RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: meta-node-0 healthcheck: test: @@ -259,11 +260,11 @@ services: - "9500" ports: - "9500:9500" - depends_on: [] + depends_on: [ ] volumes: - "prometheus-0:/prometheus" - "./prometheus.yaml:/etc/prometheus/prometheus.yml" - environment: {} + environment: { } container_name: prometheus-0 healthcheck: test: @@ -301,10 +302,10 @@ services: - "9092:9092" - "9644:9644" - "8081:8081" - depends_on: [] + depends_on: [ ] volumes: - "message_queue:/var/lib/redpanda/data" - environment: {} + environment: { } container_name: message_queue healthcheck: test: curl -f localhost:9644/v1/status/ready diff --git a/docker/docker-compose-with-local-fs.yml b/docker/docker-compose-with-local-fs.yml index aa02531db1d3e..1e15589de11b8 100644 --- a/docker/docker-compose-with-local-fs.yml +++ b/docker/docker-compose-with-local-fs.yml @@ -56,6 +56,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: diff --git a/docker/docker-compose-with-obs.yml b/docker/docker-compose-with-obs.yml index 39fb135132da5..6f105da16bd1f 100644 --- a/docker/docker-compose-with-obs.yml +++ b/docker/docker-compose-with-obs.yml @@ -58,6 +58,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: diff --git a/docker/docker-compose-with-oss.yml b/docker/docker-compose-with-oss.yml index 677d0ce82b27c..0520c8189c75e 100644 --- a/docker/docker-compose-with-oss.yml +++ b/docker/docker-compose-with-oss.yml @@ -58,6 +58,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: diff --git a/docker/docker-compose-with-s3.yml b/docker/docker-compose-with-s3.yml index 9a3d33b261aff..f5ccc3db68b3a 100644 --- a/docker/docker-compose-with-s3.yml +++ b/docker/docker-compose-with-s3.yml @@ -58,6 +58,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: diff --git a/docker/docker-compose-with-sqlite.yml b/docker/docker-compose-with-sqlite.yml index 1d495fd0e7875..7c7ec46368b19 100644 --- a/docker/docker-compose-with-sqlite.yml +++ b/docker/docker-compose-with-sqlite.yml @@ -58,6 +58,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: @@ -78,19 +79,19 @@ services: grafana-0: image: "grafana/grafana-oss:latest" - command: [] + command: [ ] expose: - "3001" ports: - "3001:3001" - depends_on: [] + depends_on: [ ] volumes: - "grafana-0:/var/lib/grafana" - "./grafana.ini:/etc/grafana/grafana.ini" - "./grafana-risedev-datasource.yml:/etc/grafana/provisioning/datasources/grafana-risedev-datasource.yml" - "./grafana-risedev-dashboard.yml:/etc/grafana/provisioning/dashboards/grafana-risedev-dashboard.yml" - "./dashboards:/dashboards" - environment: {} + environment: { } container_name: grafana-0 healthcheck: test: @@ -116,7 +117,7 @@ services: ports: - "9301:9301" - "9400:9400" - depends_on: [] + depends_on: [ ] volumes: - "minio-0:/data" entrypoint: " @@ -160,11 +161,11 @@ services: - "9500" ports: - "9500:9500" - depends_on: [] + depends_on: [ ] volumes: - "prometheus-0:/prometheus" - "./prometheus.yaml:/etc/prometheus/prometheus.yml" - environment: {} + environment: { } container_name: prometheus-0 healthcheck: test: @@ -203,10 +204,10 @@ services: - "9092:9092" - "9644:9644" - "8081:8081" - depends_on: [] + depends_on: [ ] volumes: - "message_queue:/var/lib/redpanda/data" - environment: {} + environment: { } container_name: message_queue healthcheck: test: curl -f localhost:9644/v1/status/ready diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 71280dc6e98b5..0ca5286f1a3e7 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -58,6 +58,7 @@ services: RUST_BACKTRACE: "1" # If ENABLE_TELEMETRY is not set, telemetry will start by default ENABLE_TELEMETRY: ${ENABLE_TELEMETRY:-true} + RW_TELEMETRY_TYPE: ${RW_TELEMETRY_TYPE:-"docker-compose"} container_name: risingwave-standalone healthcheck: test: @@ -98,19 +99,19 @@ services: grafana-0: image: "grafana/grafana-oss:latest" - command: [] + command: [ ] expose: - "3001" ports: - "3001:3001" - depends_on: [] + depends_on: [ ] volumes: - "grafana-0:/var/lib/grafana" - "./grafana.ini:/etc/grafana/grafana.ini" - "./grafana-risedev-datasource.yml:/etc/grafana/provisioning/datasources/grafana-risedev-datasource.yml" - "./grafana-risedev-dashboard.yml:/etc/grafana/provisioning/dashboards/grafana-risedev-dashboard.yml" - "./dashboards:/dashboards" - environment: {} + environment: { } container_name: grafana-0 healthcheck: test: @@ -136,7 +137,7 @@ services: ports: - "9301:9301" - "9400:9400" - depends_on: [] + depends_on: [ ] volumes: - "minio-0:/data" entrypoint: " @@ -180,11 +181,11 @@ services: - "9500" ports: - "9500:9500" - depends_on: [] + depends_on: [ ] volumes: - "prometheus-0:/prometheus" - "./prometheus.yaml:/etc/prometheus/prometheus.yml" - environment: {} + environment: { } container_name: prometheus-0 healthcheck: test: @@ -223,10 +224,10 @@ services: - "9092:9092" - "9644:9644" - "8081:8081" - depends_on: [] + depends_on: [ ] volumes: - "message_queue:/var/lib/redpanda/data" - environment: {} + environment: { } container_name: message_queue healthcheck: test: curl -f localhost:9644/v1/status/ready diff --git a/proto/telemetry.proto b/proto/telemetry.proto index c7ac6bb387bb1..68ee49f9caefe 100644 --- a/proto/telemetry.proto +++ b/proto/telemetry.proto @@ -19,6 +19,14 @@ enum TelemetryNodeType { TELEMETRY_NODE_TYPE_COMPACTOR = 4; } +enum TelemetryClusterType { + TELEMETRY_CLUSTER_TYPE_UNSPECIFIED = 0; + TELEMETRY_CLUSTER_TYPE_SINGLE_NODE = 1; + TELEMETRY_CLUSTER_TYPE_DOCKER_COMPOSE = 2; + TELEMETRY_CLUSTER_TYPE_KUBERNETES = 3; + TELEMETRY_CLUSTER_TYPE_CLOUD_HOSTED = 4; +} + message SystemMemory { uint64 used = 1; uint64 total = 2; @@ -88,6 +96,9 @@ message MetaReport { // stream_jobs is the list of running streaming jobs // and is used to collect the table_id, connector_name and table_optimizations repeated StreamJobDesc stream_jobs = 6; + + // How the cluster is deployed + TelemetryClusterType cluster_type = 7; } enum PlanOptimization { diff --git a/src/cmd_all/src/bin/risingwave.rs b/src/cmd_all/src/bin/risingwave.rs index c95e7a61db4d3..5a4e55c981043 100644 --- a/src/cmd_all/src/bin/risingwave.rs +++ b/src/cmd_all/src/bin/risingwave.rs @@ -15,6 +15,7 @@ #![feature(assert_matches)] #![cfg_attr(coverage, feature(coverage_attribute))] +use std::env; use std::ffi::OsString; use std::str::FromStr; @@ -23,6 +24,7 @@ use clap::{command, ArgMatches, Args, Command, CommandFactory, FromArgMatches}; use risingwave_cmd::{compactor, compute, ctl, frontend, meta}; use risingwave_cmd_all::{SingleNodeOpts, StandaloneOpts}; use risingwave_common::git_sha; +use risingwave_common::telemetry::{TELEMETRY_CLUSTER_TYPE, TELEMETRY_CLUSTER_TYPE_SINGLE_NODE}; use risingwave_compactor::CompactorOpts; use risingwave_compute::ComputeNodeOpts; use risingwave_ctl::CliOpts as CtlOpts; @@ -235,6 +237,9 @@ fn standalone(opts: StandaloneOpts) { /// high level options to standalone mode node-level options. /// We will start a standalone instance, with all nodes in the same process. fn single_node(opts: SingleNodeOpts) { + if env::var(TELEMETRY_CLUSTER_TYPE).is_err() { + env::set_var(TELEMETRY_CLUSTER_TYPE, TELEMETRY_CLUSTER_TYPE_SINGLE_NODE); + } let opts = risingwave_cmd_all::map_single_node_opts_to_standalone_opts(opts); let settings = risingwave_rt::LoggerSettings::from_opts(&opts) .with_target("risingwave_storage", Level::WARN) diff --git a/src/common/src/telemetry/mod.rs b/src/common/src/telemetry/mod.rs index 0fbd526692da0..9cf469af9cd8d 100644 --- a/src/common/src/telemetry/mod.rs +++ b/src/common/src/telemetry/mod.rs @@ -19,6 +19,7 @@ pub mod report; use std::env; use std::time::SystemTime; +use risingwave_pb::telemetry::PbTelemetryClusterType; use serde::{Deserialize, Serialize}; use sysinfo::System; use thiserror_ext::AsReport; @@ -29,8 +30,24 @@ use crate::util::resource_util::memory::{system_memory_available_bytes, total_me use crate::RW_VERSION; pub const TELEMETRY_CLUSTER_TYPE: &str = "RW_TELEMETRY_TYPE"; -const TELEMETRY_CLUSTER_TYPE_HOSTED: &str = "hosted"; // hosted on RisingWave Cloud -const TELEMETRY_CLUSTER_TYPE_TEST: &str = "test"; // test environment, eg. CI & Risedev +pub const TELEMETRY_CLUSTER_TYPE_HOSTED: &str = "hosted"; // hosted on RisingWave Cloud +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 fn telemetry_cluster_type_from_env_var() -> PbTelemetryClusterType { + let cluster_type = match env::var(TELEMETRY_CLUSTER_TYPE) { + Ok(cluster_type) => cluster_type, + Err(_) => return 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, + } +} /// Url of telemetry backend pub const TELEMETRY_REPORT_URL: &str = "https://telemetry.risingwave.dev/api/v2/report"; @@ -166,12 +183,11 @@ pub fn current_timestamp() -> u64 { } pub fn report_scarf_enabled() -> bool { - env::var(TELEMETRY_CLUSTER_TYPE) - .map(|deploy_type| { - !(deploy_type.eq_ignore_ascii_case(TELEMETRY_CLUSTER_TYPE_HOSTED) - || deploy_type.eq_ignore_ascii_case(TELEMETRY_CLUSTER_TYPE_TEST)) - }) - .unwrap_or(true) + telemetry_env_enabled() + && !matches!( + telemetry_cluster_type_from_env_var(), + PbTelemetryClusterType::CloudHosted + ) } // impl logic to report to Scarf service, containing RW version and deployment platform @@ -197,6 +213,22 @@ pub async fn report_to_scarf() { mod tests { use super::*; + #[test] + fn test_enable_scarf() { + std::env::set_var(TELEMETRY_ENV_ENABLE, "true"); + + // setting env var to `Hosted` should disable scarf + std::env::set_var(TELEMETRY_CLUSTER_TYPE, TELEMETRY_CLUSTER_TYPE_HOSTED); + assert!(!report_scarf_enabled()); + + // setting env var to `DockerCompose` should enable scarf + std::env::set_var( + TELEMETRY_CLUSTER_TYPE, + TELEMETRY_CLUSTER_TYPE_DOCKER_COMPOSE, + ); + assert!(report_scarf_enabled()); + } + #[test] fn test_system_data_new() { let system_data = SystemData::new(); diff --git a/src/meta/src/telemetry.rs b/src/meta/src/telemetry.rs index f84feff6af0a5..067322ba9b86e 100644 --- a/src/meta/src/telemetry.rs +++ b/src/meta/src/telemetry.rs @@ -19,11 +19,14 @@ use risingwave_common::telemetry::report::{ report_event_common, TelemetryInfoFetcher, TelemetryReportCreator, }; use risingwave_common::telemetry::{ - current_timestamp, SystemData, TelemetryNodeType, TelemetryReportBase, TelemetryResult, + current_timestamp, telemetry_cluster_type_from_env_var, SystemData, TelemetryNodeType, + TelemetryReportBase, TelemetryResult, }; use risingwave_common::{GIT_SHA, RW_VERSION}; use risingwave_pb::common::WorkerType; -use risingwave_pb::telemetry::{PbTelemetryDatabaseObject, PbTelemetryEventStage}; +use risingwave_pb::telemetry::{ + PbTelemetryClusterType, PbTelemetryDatabaseObject, PbTelemetryEventStage, +}; use serde::{Deserialize, Serialize}; use thiserror_ext::AsReport; @@ -88,6 +91,9 @@ pub struct MetaTelemetryReport { meta_backend: MetaBackend, rw_version: RwVersion, job_desc: Vec, + + // Get the ENV from key `TELEMETRY_CLUSTER_TYPE` + cluster_type: PbTelemetryClusterType, } impl From for risingwave_pb::telemetry::StreamJobDesc { @@ -133,6 +139,7 @@ impl TelemetryToProtobuf for MetaTelemetryReport { }), stream_job_count: self.streaming_job_count as u32, stream_jobs: self.job_desc.into_iter().map(|job| job.into()).collect(), + cluster_type: self.cluster_type as i32, }; pb_report.encode_to_vec() } @@ -219,6 +226,7 @@ impl TelemetryReportCreator for MetaReportCreator { streaming_job_count, meta_backend: self.meta_backend, job_desc: stream_job_desc, + cluster_type: telemetry_cluster_type_from_env_var(), }) } @@ -233,6 +241,7 @@ mod test { use risingwave_common::telemetry::{ current_timestamp, SystemData, TelemetryNodeType, TelemetryReportBase, }; + use risingwave_pb::telemetry::PbTelemetryClusterType; use crate::telemetry::{MetaTelemetryReport, NodeCount, RwVersion}; @@ -244,7 +253,7 @@ mod test { use crate::telemetry::TELEMETRY_META_REPORT_TYPE; - // we don't call `create_report` here because it rely on the metadata manager + // we don't call `create_report` here because it relies on the metadata manager let report = MetaTelemetryReport { base: TelemetryReportBase { tracking_id: "7d45669c-08c7-4571-ae3d-d3a3e70a2f7e".to_owned(), @@ -268,6 +277,7 @@ mod test { git_sha: "git_sha".to_owned(), }, job_desc: vec![], + cluster_type: PbTelemetryClusterType::Unspecified, }; let pb_bytes = report.to_pb_bytes();