chore: snapshot release workspace
This commit is contained in:
@@ -71,7 +71,7 @@ async fn build_telemetry_report(
|
||||
data_dir: &std::path::Path,
|
||||
) -> anyhow::Result<serde_json::Value> {
|
||||
// Anonymous node ID — truncated SHA-256 hash of pubkey
|
||||
let (node_id, version, container_count, running_count, peer_count, containers) =
|
||||
let (node_id, node_name, version, container_count, running_count, peer_count, containers) =
|
||||
if let Some(ref sm) = state {
|
||||
let (data, _) = sm.get_snapshot().await;
|
||||
let id = {
|
||||
@@ -98,6 +98,10 @@ async fn build_telemetry_report(
|
||||
.count();
|
||||
(
|
||||
id,
|
||||
data.server_info
|
||||
.name
|
||||
.clone()
|
||||
.filter(|n| !n.trim().is_empty()),
|
||||
data.server_info.version.clone(),
|
||||
data.package_data.len(),
|
||||
running,
|
||||
@@ -107,6 +111,7 @@ async fn build_telemetry_report(
|
||||
} else {
|
||||
(
|
||||
"unknown".to_string(),
|
||||
None,
|
||||
"unknown".to_string(),
|
||||
0,
|
||||
0,
|
||||
@@ -125,6 +130,8 @@ async fn build_telemetry_report(
|
||||
.and_then(|s| s.split_whitespace().next()?.parse::<f64>().ok())
|
||||
.map(|f| f as u64)
|
||||
.unwrap_or(0);
|
||||
let hostname = system_hostname().await;
|
||||
let server_url = local_server_url(data_dir).await;
|
||||
|
||||
// Latest metrics snapshot
|
||||
let latest = store.latest().await;
|
||||
@@ -166,6 +173,9 @@ async fn build_telemetry_report(
|
||||
|
||||
Ok(serde_json::json!({
|
||||
"node_id": node_id,
|
||||
"node_name": node_name,
|
||||
"hostname": hostname,
|
||||
"server_url": server_url,
|
||||
"version": version,
|
||||
"uptime_secs": uptime_secs,
|
||||
"cpu_cores": cpu_cores,
|
||||
@@ -181,6 +191,35 @@ async fn build_telemetry_report(
|
||||
}))
|
||||
}
|
||||
|
||||
async fn system_hostname() -> Option<String> {
|
||||
let output = tokio::process::Command::new("hostname")
|
||||
.output()
|
||||
.await
|
||||
.ok()?;
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
let hostname = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
(!hostname.is_empty()).then_some(hostname)
|
||||
}
|
||||
|
||||
async fn local_server_url(data_dir: &std::path::Path) -> Option<String> {
|
||||
let _ = data_dir;
|
||||
let output = tokio::process::Command::new("hostname")
|
||||
.arg("-I")
|
||||
.output()
|
||||
.await
|
||||
.ok()?;
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
let ip = String::from_utf8_lossy(&output.stdout)
|
||||
.split_whitespace()
|
||||
.find(|ip| !ip.starts_with("127.") && ip.contains('.'))?
|
||||
.to_string();
|
||||
Some(format!("https://{ip}"))
|
||||
}
|
||||
|
||||
/// POST a telemetry report to the central collector.
|
||||
async fn post_telemetry_report(url: &str, report: &serde_json::Value) -> anyhow::Result<()> {
|
||||
let client = reqwest::Client::builder()
|
||||
|
||||
Reference in New Issue
Block a user