From 251f9fbfff71151cf91d8aa31c3fd80bd85ee85a Mon Sep 17 00:00:00 2001 From: vmenge Date: Mon, 8 Jun 2026 19:06:10 +0200 Subject: [PATCH 1/2] feat(connd): primary conn metric, capability metric --- orb-connd/src/connectivity_daemon.rs | 4 +- orb-connd/src/reporters/active_connections.rs | 50 ++++++++++++++++--- orb-connd/src/reporters/mod.rs | 1 + 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/orb-connd/src/connectivity_daemon.rs b/orb-connd/src/connectivity_daemon.rs index 9c001a930..e463a6302 100644 --- a/orb-connd/src/connectivity_daemon.rs +++ b/orb-connd/src/connectivity_daemon.rs @@ -6,7 +6,7 @@ use crate::service::{self, ConndService, ProfileStorage}; use crate::systemd::Systemd; use crate::{modem, reporters, OrbCapabilities}; use color_eyre::eyre::{Context, Result}; -use orb_dogd::MetricEmitter; +use orb_dogd::{MetricEmitter, NO_TAGS}; use orb_info::orb_os_release::OrbOsRelease; use speare::mini::{self, OnErr}; use speare::Backoff; @@ -99,6 +99,8 @@ pub async fn program( .await?; if let OrbCapabilities::CellularAndWifi = cap { + let _ = statsd_client.gauge("orb.platform.connd.lte_capable", 1.0, NO_TAGS); + speare .task_with() .args(modem::Args { diff --git a/orb-connd/src/reporters/active_connections.rs b/orb-connd/src/reporters/active_connections.rs index a3daddc50..a0e724799 100644 --- a/orb-connd/src/reporters/active_connections.rs +++ b/orb-connd/src/reporters/active_connections.rs @@ -5,23 +5,29 @@ use color_eyre::eyre::{bail, eyre, Context, ContextCompat}; use color_eyre::Result; use futures::StreamExt; use oes::NetworkInterface; +use orb_dogd::MetricEmitter; use speare::mini; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::path::{Path, PathBuf}; +use std::sync::Arc; use std::time::Duration; use tokio::{fs, time}; use tracing::{error, info, warn}; -pub struct Args { +pub struct Args { pub nm: NetworkManager, pub resolved: Resolved, pub zsender: zenorb::Sender, pub procfs: PathBuf, pub sysfs: PathBuf, + pub metrics: Arc, } -pub async fn report(ctx: mini::Ctx) -> Result<()> { +pub async fn report(ctx: mini::Ctx>) -> Result<()> +where + M: MetricEmitter, +{ info!("starting active connections reporter"); async { @@ -56,6 +62,12 @@ pub async fn report(ctx: mini::Ctx) -> Result<()> { .await .wrap_err("building active connections report")?; + let _ = ctx + .metrics + .gauge("orb.platform.connd.primary_conn", 1.0, ["kind:"]); + + emit_metrics(&report, ctx.metrics.as_ref()); + publish_report(&ctx, report) .await .wrap_err("publishing active connections report")?; @@ -99,6 +111,8 @@ pub async fn report(ctx: mini::Ctx) -> Result<()> { .await .wrap_err("building active connections report")?; + emit_metrics(&report, ctx.metrics.as_ref()); + publish_report(&ctx, report) .await .wrap_err("publishing active connections report")?; @@ -113,12 +127,15 @@ pub async fn report(ctx: mini::Ctx) -> Result<()> { } /// build report based on NM inputs and system inspection -async fn build_report( +async fn build_report( primary: &Option, connection_state: ConnectionState, active_conns: &Vec, - ctx: &mini::Ctx, -) -> Result { + ctx: &mini::Ctx>, +) -> Result +where + M: MetricEmitter, +{ let connectivity_uri = ctx.nm.connectivity_check_uri().await?; let hostname = hostname_from_uri(&connectivity_uri).map(str::to_string); let mut connections = Vec::new(); @@ -197,10 +214,27 @@ struct Connection { http_check: Result, } -async fn publish_report( - ctx: &mini::Ctx, +fn emit_metrics(report: &ActiveConnections, metrics: &impl MetricEmitter) { + for c in &report.connections { + if c.primary { + let _ = metrics.gauge( + "orb.platform.connd.primary_conn", + 1.0, + [format!("kind:{}", c.iface)], + ); + + return; + } + } +} + +async fn publish_report( + ctx: &mini::Ctx>, report: ActiveConnections, -) -> Result<()> { +) -> Result<()> +where + M: MetricEmitter, +{ info!("{report:#?}"); let report: oes::ActiveConnections = report.try_into()?; diff --git a/orb-connd/src/reporters/mod.rs b/orb-connd/src/reporters/mod.rs index 7ba610212..a15f626ba 100644 --- a/orb-connd/src/reporters/mod.rs +++ b/orb-connd/src/reporters/mod.rs @@ -71,6 +71,7 @@ pub async fn spawn( zsender, sysfs, procfs, + metrics: statsd.clone(), }) .on_err(static_backoff(15)) .spawn(active_connections::report)?; From 6093ff877b96fef97eec356df0827c28a0260418 Mon Sep 17 00:00:00 2001 From: vmenge Date: Mon, 8 Jun 2026 19:07:08 +0200 Subject: [PATCH 2/2] remove unneeded gauge --- orb-connd/src/reporters/active_connections.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/orb-connd/src/reporters/active_connections.rs b/orb-connd/src/reporters/active_connections.rs index a0e724799..801561439 100644 --- a/orb-connd/src/reporters/active_connections.rs +++ b/orb-connd/src/reporters/active_connections.rs @@ -62,10 +62,6 @@ where .await .wrap_err("building active connections report")?; - let _ = ctx - .metrics - .gauge("orb.platform.connd.primary_conn", 1.0, ["kind:"]); - emit_metrics(&report, ctx.metrics.as_ref()); publish_report(&ctx, report)