Skip to content

Commit

Permalink
add new field in telemetry
Browse files Browse the repository at this point in the history
Signed-off-by: tabVersion <[email protected]>
  • Loading branch information
tabVersion committed Aug 13, 2024
1 parent cad31da commit 8bf2003
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions proto/telemetry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ message ReportBase {
// mark the report is a test message
// if so, the backend do validations but not store it
bool is_test = 7;
// cloud_uuid is the unique identifier of the cloud instance
optional string cloud_uuid = 8;
}

message MetaReport {
Expand Down Expand Up @@ -165,4 +167,6 @@ message EventMessage {
string node = 9;
// mark the event is a test message
bool is_test = 11;
// cloud_uuid is the unique identifier of the cloud instance
optional string cloud_uuid = 12;
}
7 changes: 7 additions & 0 deletions src/common/src/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ 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";

// 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 telemetry_cluster_type_from_env_var() -> PbTelemetryClusterType {
let cluster_type = match env::var(TELEMETRY_CLUSTER_TYPE) {
Ok(cluster_type) => cluster_type,
Expand Down
3 changes: 2 additions & 1 deletion src/common/src/telemetry/pb_compatible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use risingwave_common::telemetry::get_telemetry_risingwave_cloud_uuid;
use risingwave_pb::telemetry::{
ReportBase as PbTelemetryReportBase, SystemCpu as PbSystemCpu, SystemData as PbSystemData,
SystemMemory as PbSystemMemory, SystemOs as PbSystemOs,
Expand All @@ -27,6 +27,7 @@ pub trait TelemetryToProtobuf {
impl From<TelemetryReportBase> for PbTelemetryReportBase {
fn from(val: TelemetryReportBase) -> Self {
PbTelemetryReportBase {
cloud_uuid: get_telemetry_risingwave_cloud_uuid(),
tracking_id: val.tracking_id,
session_id: val.session_id,
system_data: Some(val.system_data.into()),
Expand Down
6 changes: 5 additions & 1 deletion src/common/src/telemetry/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ use tokio::task::JoinHandle;
use tokio::time::{interval, Duration};
use uuid::Uuid;

use super::{current_timestamp, Result, TELEMETRY_REPORT_INTERVAL, TELEMETRY_REPORT_URL};
use super::{
current_timestamp, get_telemetry_risingwave_cloud_uuid, Result, TELEMETRY_REPORT_INTERVAL,
TELEMETRY_REPORT_URL,
};
use crate::telemetry::pb_compatible::TelemetryToProtobuf;
use crate::telemetry::post_telemetry_report_pb;

Expand Down Expand Up @@ -179,6 +182,7 @@ fn request_to_telemetry_event(
attributes: attributes.map(|a| a.to_string()),
node,
is_test,
cloud_uuid: get_telemetry_risingwave_cloud_uuid(),
};
let report_bytes = event.encode_to_vec();

Expand Down

0 comments on commit 8bf2003

Please sign in to comment.