Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage report cli dump & settings tweaks #908

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions file_store/src/cli/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
mobile_subscriber::{SubscriberLocationIngestReport, VerifiedSubscriberLocationIngestReport},
speedtest::{CellSpeedtest, CellSpeedtestIngestReport},
traits::{MsgDecode, TimestampDecode},
usage_counts::{HexUsageCountsIngestReport, RadioUsageCountsIngestReport},
wifi_heartbeat::WifiHeartbeatIngestReport,
FileType, Result, Settings,
};
Expand All @@ -26,8 +27,9 @@ use helium_proto::{
},
poc_mobile::{
mobile_reward_share::Reward, CellHeartbeatIngestReportV1, CellHeartbeatReqV1,
CoverageObjectV1, Heartbeat, InvalidDataTransferIngestReportV1, MobileRewardShare,
OracleBoostingReportV1, RadioRewardShare, SpeedtestAvg, SpeedtestIngestReportV1,
CoverageObjectV1, Heartbeat, HexUsageStatsIngestReportV1,
InvalidDataTransferIngestReportV1, MobileRewardShare, OracleBoostingReportV1,
RadioRewardShare, RadioUsageStatsIngestReportV1, SpeedtestAvg, SpeedtestIngestReportV1,
SpeedtestReqV1, VerifiedInvalidatedRadioThresholdIngestReportV1,
VerifiedRadioThresholdIngestReportV1,
},
Expand Down Expand Up @@ -57,6 +59,16 @@ impl Cmd {
while let Some(result) = file_stream.next().await {
let msg = result?;
match self.file_type {
FileType::HexUsageStatsIngestReport => {
let dec_msg = HexUsageStatsIngestReportV1::decode(msg)?;
let report = HexUsageCountsIngestReport::try_from(dec_msg)?;
print_json(&report)?;
}
FileType::RadioUsageStatsIngestReport => {
let dec_msg = RadioUsageStatsIngestReportV1::decode(msg)?;
let report = RadioUsageCountsIngestReport::try_from(dec_msg)?;
print_json(&report)?;
}
FileType::VerifiedRadioThresholdIngestReport => {
let dec_msg = VerifiedRadioThresholdIngestReportV1::decode(msg)?;
let report = VerifiedRadioThresholdIngestReport::try_from(dec_msg)?;
Expand Down
34 changes: 17 additions & 17 deletions file_store/src/usage_counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,34 @@ impl MsgDecode for RadioUsageStatsReq {

impl MsgTimestamp<Result<DateTime<Utc>>> for HexUsageStatsReqV1 {
fn timestamp(&self) -> Result<DateTime<Utc>> {
self.timestamp.to_timestamp_millis()
self.timestamp.to_timestamp()
}
}

impl MsgTimestamp<u64> for HexUsageStatsReq {
fn timestamp(&self) -> u64 {
self.timestamp.encode_timestamp_millis()
self.timestamp.encode_timestamp()
}
}

impl MsgTimestamp<Result<DateTime<Utc>>> for RadioUsageStatsReqV1 {
fn timestamp(&self) -> Result<DateTime<Utc>> {
self.timestamp.to_timestamp_millis()
self.timestamp.to_timestamp()
}
}

impl MsgTimestamp<u64> for RadioUsageStatsReq {
fn timestamp(&self) -> u64 {
self.timestamp.encode_timestamp_millis()
self.timestamp.encode_timestamp()
}
}

impl TryFrom<HexUsageStatsReqV1> for HexUsageStatsReq {
type Error = Error;
fn try_from(v: HexUsageStatsReqV1) -> Result<Self> {
let timestamp = v.timestamp()?;
let epoch_start_timestamp = v.epoch_start_timestamp.to_timestamp_millis()?;
let epoch_end_timestamp = v.epoch_end_timestamp.to_timestamp_millis()?;
let epoch_start_timestamp = v.epoch_start_timestamp.to_timestamp()?;
let epoch_end_timestamp = v.epoch_end_timestamp.to_timestamp()?;
let hex = CellIndex::try_from(v.hex).map_err(|_| {
DecodeError::FileStreamTryDecode(format!("invalid CellIndex {}", v.hex))
})?;
Expand All @@ -102,8 +102,8 @@ impl TryFrom<HexUsageStatsReqV1> for HexUsageStatsReq {
impl From<HexUsageStatsReq> for HexUsageStatsReqV1 {
fn from(v: HexUsageStatsReq) -> Self {
let timestamp = v.timestamp();
let epoch_start_timestamp = v.epoch_start_timestamp.encode_timestamp_millis();
let epoch_end_timestamp = v.epoch_end_timestamp.encode_timestamp_millis();
let epoch_start_timestamp = v.epoch_start_timestamp.encode_timestamp();
let epoch_end_timestamp = v.epoch_end_timestamp.encode_timestamp();

HexUsageStatsReqV1 {
hex: v.hex.into(),
Expand All @@ -125,8 +125,8 @@ impl TryFrom<RadioUsageStatsReqV1> for RadioUsageStatsReq {
type Error = Error;
fn try_from(v: RadioUsageStatsReqV1) -> Result<Self> {
let timestamp = v.timestamp()?;
let epoch_start_timestamp = v.epoch_start_timestamp.to_timestamp_millis()?;
let epoch_end_timestamp = v.epoch_end_timestamp.to_timestamp_millis()?;
let epoch_start_timestamp = v.epoch_start_timestamp.to_timestamp()?;
let epoch_end_timestamp = v.epoch_end_timestamp.to_timestamp()?;
Ok(Self {
hotspot_pubkey: v.hotspot_pubkey.into(),
cbsd_id: v.cbsd_id,
Expand All @@ -146,8 +146,8 @@ impl TryFrom<RadioUsageStatsReqV1> for RadioUsageStatsReq {
impl From<RadioUsageStatsReq> for RadioUsageStatsReqV1 {
fn from(v: RadioUsageStatsReq) -> Self {
let timestamp = v.timestamp();
let epoch_start_timestamp = v.epoch_start_timestamp.encode_timestamp_millis();
let epoch_end_timestamp = v.epoch_end_timestamp.encode_timestamp_millis();
let epoch_start_timestamp = v.epoch_start_timestamp.encode_timestamp();
let epoch_end_timestamp = v.epoch_end_timestamp.encode_timestamp();

RadioUsageStatsReqV1 {
hotspot_pubkey: v.hotspot_pubkey.into(),
Expand Down Expand Up @@ -188,25 +188,25 @@ impl MsgDecode for RadioUsageCountsIngestReport {

impl MsgTimestamp<Result<DateTime<Utc>>> for HexUsageStatsIngestReportV1 {
fn timestamp(&self) -> Result<DateTime<Utc>> {
self.received_timestamp.to_timestamp()
self.received_timestamp.to_timestamp_millis()
}
}

impl MsgTimestamp<u64> for HexUsageCountsIngestReport {
fn timestamp(&self) -> u64 {
self.received_timestamp.encode_timestamp()
self.received_timestamp.encode_timestamp_millis()
}
}

impl MsgTimestamp<Result<DateTime<Utc>>> for RadioUsageStatsIngestReportV1 {
fn timestamp(&self) -> Result<DateTime<Utc>> {
self.received_timestamp.to_timestamp()
self.received_timestamp.to_timestamp_millis()
}
}

impl MsgTimestamp<u64> for RadioUsageCountsIngestReport {
fn timestamp(&self) -> u64 {
self.received_timestamp.encode_timestamp()
self.received_timestamp.encode_timestamp_millis()
}
}

Expand All @@ -230,7 +230,7 @@ impl From<HexUsageCountsIngestReport> for HexUsageStatsIngestReportV1 {
let report: HexUsageStatsReqV1 = v.report.into();
Self {
report: Some(report),
received_timestamp: received_timestamp.encode_timestamp(),
received_timestamp: received_timestamp.encode_timestamp_millis(),
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion ingest/src/server_mobile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ pub async fn grpc_server(settings: &Settings) -> Result<()> {
bail!("expected valid api token in settings");
};

let Some(config_client) = settings.config_client.as_ref() else {
bail!("expected mobile config client settings");
};

let grpc_server = GrpcServer::new(
heartbeat_report_sink,
wifi_heartbeat_report_sink,
Expand All @@ -676,7 +680,7 @@ pub async fn grpc_server(settings: &Settings) -> Result<()> {
settings.network,
settings.listen_addr,
api_token,
AuthorizationClient::from_settings(&settings.config_client)?,
AuthorizationClient::from_settings(config_client)?,
);

tracing::info!(
Expand Down
3 changes: 2 additions & 1 deletion ingest/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub struct Settings {
/// Target output bucket details Metrics settings
pub metrics: poc_metrics::Settings,
// mobile config client settings
pub config_client: mobile_config::ClientSettings,
// optional to avoid having to define a client for IOT mode
pub config_client: Option<mobile_config::ClientSettings>,
}

fn default_roll_time() -> Duration {
Expand Down