Skip to content

Commit

Permalink
add version to clientStatsReport (#5147)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwicky authored Nov 18, 2024
1 parent 99e4ff9 commit 05b55a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/statistics/src/clients/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl ClientStatsController {
gateway_conn_stats: self.gateway_conn_stats.report(),
nym_api_stats: self.nym_api_stats.report(),
connection_stats: self.connection_stats.report(),
..Default::default()
}
}

Expand Down
22 changes: 22 additions & 0 deletions common/statistics/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ use serde::{Deserialize, Serialize};
use sysinfo::System;
use time::OffsetDateTime;

const KIND: &str = "client_stats_report";
const VERSION: &str = "v1";

/// Report object containing both data to be reported and client / device context. We take extra care not to overcapture context information.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ClientStatsReport {
pub(crate) kind: String,
pub(crate) api_version: String,
pub(crate) last_update_time: OffsetDateTime,
pub(crate) client_id: String,
pub(crate) client_type: String,
Expand All @@ -41,6 +46,23 @@ impl TryFrom<&[u8]> for ClientStatsReport {
}
}

impl Default for ClientStatsReport {
fn default() -> Self {
ClientStatsReport {
kind: KIND.to_string(),
api_version: VERSION.to_string(),
last_update_time: OffsetDateTime::now_utc(),
client_id: Default::default(),
client_type: Default::default(),
os_information: Default::default(),
packet_stats: Default::default(),
gateway_conn_stats: Default::default(),
nym_api_stats: Default::default(),
connection_stats: Default::default(),
}
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct OsInformation {
pub(crate) os_type: String,
Expand Down

0 comments on commit 05b55a1

Please sign in to comment.