Skip to content

Commit 77cdbbc

Browse files
committed
improved telemetry system and hardware data
1 parent 475fe20 commit 77cdbbc

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

Cargo.lock

+28-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phichain-editor/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ smallvec = "1.13.2"
9797
uuid = { version = "1.13.1", features = ["v4"] }
9898

9999
bevy_mod_reqwest = "0.18.0"
100+
os_info = "3.10.0"
101+
sysinfo = "0.33.1"

phichain-editor/src/telemetry.rs

+24-7
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ use bevy::time::common_conditions::on_timer;
1010
use bevy_mod_reqwest::{BevyReqwest, ReqwestErrorEvent, ReqwestResponseEvent};
1111
use bevy_persistent::Persistent;
1212
use serde_json::{json, Value};
13-
use std::env;
1413
use std::path::Path;
1514
use std::time::Duration;
15+
use std::{env, process};
16+
use sysinfo::Pid;
1617
use uuid::Uuid;
1718

1819
const TELEMETRY_URL: &str = "https://telemetry.phichain.rs/report";
@@ -145,17 +146,33 @@ fn handle_push_telemetry_event_system(
145146
fps = value;
146147
}
147148

149+
let mut system = sysinfo::System::new_all();
150+
system.refresh_all();
151+
152+
let pid = process::id();
153+
let process = system.process(Pid::from_u32(pid)).unwrap();
154+
155+
let info = os_info::get();
156+
148157
let payload = json!({
149158
"timestamp": chrono::Utc::now().to_rfc3339(),
150159
"reporter": "phichain-editor",
151160
"uuid": telemetry_manager.uuid,
152161
"type": event.event_type,
153162
"system": {
154-
"os": system_info.os.trim(),
163+
"arch": env::consts::ARCH,
164+
"os": env::consts::OS,
165+
"name": &info.os_type().to_string(),
166+
"version": &info.version().to_string(),
167+
"family": env::consts::FAMILY,
168+
"bitness": info.bitness().to_string(),
155169
"kernel": system_info.kernel.trim(),
156-
"cpu": system_info.cpu.trim(),
157-
"core_count": system_info.core_count.trim(),
158-
"memory": system_info.memory.trim(),
170+
},
171+
"hardware": {
172+
"cpu": system.cpus().first().unwrap().brand(),
173+
"core_count": system.cpus().len(),
174+
"memory": system.total_memory(),
175+
"memory_formatted": format!("{:.1} GiB", system.total_memory() as f64 / 1024.0 / 1024.0 / 1024.0),
159176
},
160177
"adapter": &***adapter_info,
161178
"environment": {
@@ -171,8 +188,8 @@ fn handle_push_telemetry_event_system(
171188
"performance": {
172189
"fps": fps,
173190
"entities": entities.len(),
174-
"cpu": 0.5, // TODO
175-
"memory": 1024, // TODO
191+
"cpu": process.cpu_usage(),
192+
"memory": process.memory(),
176193
},
177194
"config": **editor_settings,
178195
"uptime": time.elapsed().as_secs_f32(),

0 commit comments

Comments
 (0)