Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion orb-connd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ clap = { workspace = true, features = ["derive"] }
color-eyre.workspace = true
dashmap.workspace = true
derive_more = { workspace = true, default-features = false, features = ["display"] }
dogstatsd.workspace = true
flume.workspace = true
futures.workspace = true
hex.workspace = true
Expand All @@ -33,6 +32,7 @@ oes.workspace = true
orb-backend-status-dbus.workspace = true
orb-build-info.workspace = true
orb-connd-dbus.workspace = true
orb-dogd.workspace = true
orb-info = { workspace = true, features = ["orb-os-release", "async"] }
orb-secure-storage-ca = { workspace = true, default-features = false, features = [
"backend-in-memory",
Expand Down
6 changes: 3 additions & 3 deletions orb-connd/src/connectivity_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::modem_manager::ModemManager;
use crate::network_manager::NetworkManager;
use crate::resolved::Resolved;
use crate::service::{self, ConndService, ProfileStorage};
use crate::statsd::StatsdClient;
use crate::systemd::Systemd;
use crate::{modem, reporters, OrbCapabilities};
use color_eyre::eyre::{Context, Result};
use orb_dogd::MetricEmitter;
use orb_info::orb_os_release::OrbOsRelease;
use speare::mini::{self, OnErr};
use speare::Backoff;
Expand All @@ -26,7 +26,7 @@ pub async fn program(
resolved: Resolved,
session_bus: zbus::Connection,
os_release: OrbOsRelease,
statsd_client: impl StatsdClient,
statsd_client: impl MetricEmitter,
modem_manager: impl ModemManager,
mcu_util: impl McuUtil,
connect_timeout: Duration,
Expand All @@ -37,7 +37,7 @@ pub async fn program(
let procfs = procfs.as_ref().to_path_buf();
let modem_manager: Arc<dyn ModemManager> = Arc::new(modem_manager);
let mcu_util: Arc<dyn McuUtil> = Arc::new(mcu_util);
let statsd_client: Arc<dyn StatsdClient> = Arc::new(statsd_client);
let statsd_client = Arc::new(statsd_client);

let cap = OrbCapabilities::from_sysfs(&sysfs).await;

Expand Down
1 change: 0 additions & 1 deletion orb-connd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub mod reporters;
pub mod resolved;
pub mod secure_storage;
pub mod service;
pub mod statsd;
pub mod systemd;
pub mod wpa_ctrl;

Expand Down
2 changes: 1 addition & 1 deletion orb-connd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use orb_connd::{
resolved::Resolved,
secure_storage::{self, ConndStorageScopes, SecureStorage},
service::ProfileStorage,
statsd::dd::DogstatsdClient,
systemd::Systemd,
wpa_ctrl::cli::WpaCli,
};
use orb_dogd::DogstatsdClient;
use orb_info::{
orb_os_release::{OrbOsPlatform, OrbOsRelease},
OrbId,
Expand Down
36 changes: 15 additions & 21 deletions orb-connd/src/reporters/data_usage.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
use crate::{
statsd::StatsdClient,
systemd::{IpAccounting, ServiceProxyExt, Systemd},
};
use crate::systemd::{IpAccounting, ServiceProxyExt, Systemd};
use color_eyre::Result;
use orb_dogd::MetricEmitter;
use speare::mini;
use std::{collections::HashMap, sync::Arc, time::Duration};
use tokio::time;
use tracing::{info, warn};

pub struct Args {
pub statsd: Arc<dyn StatsdClient>,
pub struct Args<M: MetricEmitter> {
pub statsd: Arc<M>,
pub systemd: Systemd,
}

pub async fn report(ctx: mini::Ctx<Args>) -> Result<()> {
pub async fn report(ctx: mini::Ctx<Args<impl MetricEmitter>>) -> Result<()> {
info!("starting data usage reporter");

let mut data_usage_map: HashMap<String, IpAccounting> = HashMap::new();
Expand Down Expand Up @@ -46,23 +44,19 @@ pub async fn report(ctx: mini::Ctx<Args>) -> Result<()> {
let tags = vec![format!("service:{unit}")];

if ingress_diff > 0 {
ctx.statsd
.count(
"orb.platform.connd.service_ingress_bytes",
ingress_diff as i64,
tags.clone(),
)
.await?;
let _ = ctx.statsd.count(
"orb.platform.connd.service_ingress_bytes",
ingress_diff as i64,
tags.clone(),
);
}

if egress_diff > 0 {
ctx.statsd
.count(
"orb.platform.connd.service_egress_bytes",
egress_diff as i64,
tags,
)
.await?;
let _ = ctx.statsd.count(
"orb.platform.connd.service_egress_bytes",
egress_diff as i64,
tags,
);
}
}

Expand Down
43 changes: 20 additions & 23 deletions orb-connd/src/reporters/datadog.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use crate::{modem, statsd::StatsdClient};
use crate::modem;
use color_eyre::Result;
use flume::Receiver;
use orb_dogd::{MetricEmitter, NO_TAGS};
use speare::mini;
use std::{collections::HashMap, sync::Arc};
use tracing::{info, warn};

pub struct Args {
pub statsd: Arc<dyn StatsdClient>,
pub struct Args<M: MetricEmitter> {
pub statsd: Arc<M>,
}

pub async fn report(ctx: mini::Ctx<Args>) -> Result<()> {
pub async fn report(ctx: mini::Ctx<Args<impl MetricEmitter>>) -> Result<()> {
info!("starting datadog reporter");

async {
Expand Down Expand Up @@ -46,7 +47,7 @@ pub async fn report(ctx: mini::Ctx<Args>) -> Result<()> {
.inspect_err(|e| warn!("failure reporting to datadog {e:?}"))
}

async fn report_modem(statsd: &dyn StatsdClient, m: modem::Snapshot) -> Result<()> {
async fn report_modem(statsd: &impl MetricEmitter, m: modem::Snapshot) -> Result<()> {
let sig = m.signal;

let gauges = vec![
Expand All @@ -65,21 +66,21 @@ async fn report_modem(statsd: &dyn StatsdClient, m: modem::Snapshot) -> Result<(
.flatten()
.collect();

statsd.count("orb.lte.heartbeat", 1, heartbeat_tags).await?;
let _ = statsd.count("orb.lte.heartbeat", 1, heartbeat_tags);
}

for (name, v) in gauges
.into_iter()
.filter_map(|(name, opt)| opt.map(|v| (name, v)))
{
statsd.gauge(name, &v.to_string(), Vec::new()).await?;
let _ = statsd.gauge(name, v, NO_TAGS);
}

Ok(())
}

async fn report_netstats(
statsd: &dyn StatsdClient,
statsd: &impl MetricEmitter,
old_netstats: &oes::NetStats,
new_netstats: &oes::NetStats,
) -> Result<()> {
Expand All @@ -90,21 +91,17 @@ async fn report_netstats(
return Ok(());
}

statsd
.incr_by_value(
&format!("orb.{}.net.rx_bytes_delta", new_netstats.iface),
rx_bytes as i64,
Vec::new(),
)
.await?;

statsd
.incr_by_value(
&format!("orb.{}.net.tx_bytes_delta", new_netstats.iface),
tx_bytes as i64,
Vec::new(),
)
.await?;
let _ = statsd.count(
format!("orb.{}.net.rx_bytes_delta", new_netstats.iface),
rx_bytes as i64,
NO_TAGS,
);

let _ = statsd.count(
format!("orb.{}.net.tx_bytes_delta", new_netstats.iface),
tx_bytes as i64,
NO_TAGS,
);

Ok(())
}
8 changes: 3 additions & 5 deletions orb-connd/src/reporters/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::{
network_manager::NetworkManager, resolved::Resolved, statsd::StatsdClient,
systemd::Systemd,
};
use crate::{network_manager::NetworkManager, resolved::Resolved, systemd::Systemd};
use color_eyre::Result;
use orb_dogd::MetricEmitter;
use speare::{mini::OnErr, Backoff, Limit};
use std::{path::PathBuf, sync::Arc, time::Duration};
use tracing::info;
Expand All @@ -20,7 +18,7 @@ pub async fn spawn(
nm: NetworkManager,
resolved: Resolved,
session_bus: zbus::Connection,
statsd: Arc<dyn StatsdClient>,
statsd: Arc<impl MetricEmitter>,
systemd: Systemd,
zsender: zenorb::Sender,
sysfs: PathBuf,
Expand Down
Loading
Loading