[PATCH datacenter-manager v2 18/25] metric collection: clarify naming for remote metric collection

Lukas Wagner
2026-03-19T09:47:17Z

Primarily to avoid confusion with the new task that will be added for
local metric collection.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
Tested-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
cli/client/src/metric_collection.rs | 4 ++--
lib/pdm-api-types/src/metric_collection.rs | 2 +-
lib/pdm-client/src/lib.rs | 6 +++---
server/src/api/metric_collection.rs | 10 +++++-----
server/src/api/remotes.rs | 2 +-
server/src/api/rrd_common.rs | 2 +-
server/src/metric_collection/mod.rs | 19 +++++++++++--------
...tion_task.rs => remote_collection_task.rs} | 8 ++++----
server/src/metric_collection/rrd_task.rs | 2 +-
server/src/metric_collection/state.rs | 2 +-
10 files changed, 30 insertions(+), 27 deletions(-)
rename server/src/metric_collection/{collection_task.rs => remote_collection_task.rs} (99%)

diff --git a/cli/client/src/metric_collection.rs b/cli/client/src/metric_collection.rs
index e9dbd804..77dcaab5 100644
--- a/cli/client/src/metric_collection.rs
+++ b/cli/client/src/metric_collection.rs
@@ -34,7 +34,7 @@ pub fn cli() -> CommandLineInterface {
/// all.
async fn trigger_metric_collection(remote: Option<String>) -> Result<(), Error> {
client()?
- .trigger_metric_collection(remote.as_deref())
+ .trigger_remote_metric_collection(remote.as_deref())
.await?;
Ok(())
}
@@ -42,7 +42,7 @@ async fn trigger_metric_collection(remote: Option<String>) -> Result<(), Error>
#[api]
/// Show metric collection status.
async fn metric_collection_status() -> Result<(), Error> {
- let result = client()?.get_metric_collection_status().await?;
+ let result = client()?.get_remote_metric_collection_status().await?;

let output_format = env().format_args.output_format;
if output_format == OutputFormat::Text {
diff --git a/lib/pdm-api-types/src/metric_collection.rs b/lib/pdm-api-types/src/metric_collection.rs
index 5279c8a4..cda6ac2a 100644
--- a/lib/pdm-api-types/src/metric_collection.rs
+++ b/lib/pdm-api-types/src/metric_collection.rs
@@ -8,7 +8,7 @@ use proxmox_schema::api;
#[derive(Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
/// Per-remote collection status.
-pub struct MetricCollectionStatus {
+pub struct RemoteMetricCollectionStatus {
/// The remote's name.
pub remote: String,
/// Any error that occured during the last collection attempt.
diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs
index 0fee97a7..7ce9c244 100644
--- a/lib/pdm-client/src/lib.rs
+++ b/lib/pdm-client/src/lib.rs
@@ -347,7 +347,7 @@ impl<T: HttpApiClient> PdmClient<T> {
}

/// Trigger metric collection for a single remote or for all remotes, if no remote is provided.
- pub async fn trigger_metric_collection(
+ pub async fn trigger_remote_metric_collection(
&self,
remote: Option<&str>,
) -> Result<(), proxmox_client::Error> {
@@ -368,9 +368,9 @@ impl<T: HttpApiClient> PdmClient<T> {
}

/// Get global metric collection status.
- pub async fn get_metric_collection_status(
+ pub async fn get_remote_metric_collection_status(
&self,
- ) -> Result<Vec<pdm_api_types::MetricCollectionStatus>, Error> {
+ ) -> Result<Vec<pdm_api_types::RemoteMetricCollectionStatus>, Error> {
let path = "/api2/extjs/remotes/metric-collection/status";
Ok(self.0.get(path).await?.expect_json()?.data)
}
diff --git a/server/src/api/metric_collection.rs b/server/src/api/metric_collection.rs
index b4c81c68..5a480b36 100644
--- a/server/src/api/metric_collection.rs
+++ b/server/src/api/metric_collection.rs
@@ -4,7 +4,7 @@ use proxmox_router::{Router, SubdirMap};
use proxmox_schema::api;
use proxmox_sortable_macro::sortable;

-use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, MetricCollectionStatus};
+use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, RemoteMetricCollectionStatus};

use crate::metric_collection;

@@ -34,7 +34,7 @@ const SUBDIRS: SubdirMap = &sorted!([
)]
/// Trigger metric collection for a provided remote or for all remotes if no remote is passed.
pub async fn trigger_metric_collection(remote: Option<String>) -> Result<(), Error> {
- crate::metric_collection::trigger_metric_collection(remote, false).await?;
+ crate::metric_collection::trigger_remote_metric_collection(remote, false).await?;

Ok(())
}
@@ -44,11 +44,11 @@ pub async fn trigger_metric_collection(remote: Option<String>) -> Result<(), Err
type: Array,
description: "A list of metric collection statuses.",
items: {
- type: MetricCollectionStatus,
+ type: RemoteMetricCollectionStatus,
}
}
)]
/// Read metric collection status.
-fn get_metric_collection_status() -> Result<Vec<MetricCollectionStatus>, Error> {
- metric_collection::get_status()
+fn get_metric_collection_status() -> Result<Vec<RemoteMetricCollectionStatus>, Error> {
+ metric_collection::remote_metric_collection_status()
}
diff --git a/server/src/api/remotes.rs b/server/src/api/remotes.rs
index 9700611d..678e0ed2 100644
--- a/server/src/api/remotes.rs
+++ b/server/src/api/remotes.rs
@@ -324,7 +324,7 @@ pub async fn add_remote(mut entry: Remote, create_token: Option<String>) -> Resu

pdm_config::remotes::save_config(remotes)?;

- if let Err(e) = metric_collection::trigger_metric_collection(Some(name), false).await {
+ if let Err(e) = metric_collection::trigger_remote_metric_collection(Some(name), false).await {
log::error!("could not trigger metric collection after adding remote: {e}");
}

diff --git a/server/src/api/rrd_common.rs b/server/src/api/rrd_common.rs
index b5d1a786..8c0fb798 100644
--- a/server/src/api/rrd_common.rs
+++ b/server/src/api/rrd_common.rs
@@ -74,7 +74,7 @@ pub async fn get_rrd_datapoints<T: DataPoint + Send + 'static>(
// is super slow or if the metric collection tasks currently busy with collecting other
// metrics, we just return the data we already have, not the newest one.
let _ = tokio::time::timeout(WAIT_FOR_NEWEST_METRIC_TIMEOUT, async {
- metric_collection::trigger_metric_collection(Some(remote), true).await
+ metric_collection::trigger_remote_metric_collection(Some(remote), true).await
})
.await;
}
diff --git a/server/src/metric_collection/mod.rs b/server/src/metric_collection/mod.rs
index 0e6860fc..6bc534f8 100644
--- a/server/src/metric_collection/mod.rs
+++ b/server/src/metric_collection/mod.rs
@@ -7,16 +7,16 @@ use nix::sys::stat::Mode;
use tokio::sync::mpsc::{self, Sender};
use tokio::sync::oneshot;

-use pdm_api_types::MetricCollectionStatus;
+use pdm_api_types::RemoteMetricCollectionStatus;
use pdm_buildcfg::PDM_STATE_DIR_M;

-mod collection_task;
+mod remote_collection_task;
pub mod rrd_cache;
mod rrd_task;
mod state;
pub mod top_entities;

-use collection_task::{ControlMsg, MetricCollectionTask};
+use remote_collection_task::{ControlMsg, RemoteMetricCollectionTask};
use rrd_cache::RrdCache;

const RRD_CACHE_BASEDIR: &str = concat!(PDM_STATE_DIR_M!(), "/rrdb");
@@ -46,7 +46,7 @@ pub fn start_task() -> Result<(), Error> {

tokio::spawn(async move {
let metric_collection_task_future = pin!(async move {
- match MetricCollectionTask::new(metric_data_tx, trigger_collection_rx) {
+ match RemoteMetricCollectionTask::new(metric_data_tx, trigger_collection_rx) {
Ok(mut task) => task.run().await,
Err(err) => log::error!("could not start metric collection task: {err}"),
}
@@ -76,7 +76,10 @@ pub fn start_task() -> Result<(), Error> {
///
/// Has no effect if the tx end of the channel has not been initialized yet.
/// Returns an error if the mpsc channel has been closed already.
-pub async fn trigger_metric_collection(remote: Option<String>, wait: bool) -> Result<(), Error> {
+pub async fn trigger_remote_metric_collection(
+ remote: Option<String>,
+ wait: bool,
+) -> Result<(), Error> {
let (done_sender, done_receiver) = oneshot::channel();

if let Some(sender) = CONTROL_MESSAGE_TX.get() {
@@ -93,15 +96,15 @@ pub async fn trigger_metric_collection(remote: Option<String>, wait: bool) -> Re
}

/// Get each remote's metric collection status.
-pub fn get_status() -> Result<Vec<MetricCollectionStatus>, Error> {
+pub fn remote_metric_collection_status() -> Result<Vec<RemoteMetricCollectionStatus>, Error> {
let (remotes, _) = pdm_config::remotes::config()?;
- let state = collection_task::load_state()?;
+ let state = remote_collection_task::load_state()?;

let mut result = Vec::new();

for (remote, _) in remotes.into_iter() {
if let Some(status) = state.get_status(&remote) {
- result.push(MetricCollectionStatus {
+ result.push(RemoteMetricCollectionStatus {
remote,
error: status.error.clone(),
last_collection: status.last_collection,
diff --git a/server/src/metric_collection/collection_task.rs b/server/src/metric_collection/remote_collection_task.rs
similarity index 99%
rename from server/src/metric_collection/collection_task.rs
rename to server/src/metric_collection/remote_collection_task.rs
index cc1a460e..eca0e11d 100644
--- a/server/src/metric_collection/collection_task.rs
+++ b/server/src/metric_collection/remote_collection_task.rs
@@ -46,13 +46,13 @@ pub(super) enum ControlMsg {

/// Task which periodically collects metrics from all remotes and stores
/// them in the local metrics database.
-pub(super) struct MetricCollectionTask {
+pub(super) struct RemoteMetricCollectionTask {
state: MetricCollectionState,
metric_data_tx: Sender<RrdStoreRequest>,
control_message_rx: Receiver<ControlMsg>,
}

-impl MetricCollectionTask {
+impl RemoteMetricCollectionTask {
/// Create a new metric collection task.
pub(super) fn new(
metric_data_tx: Sender<RrdStoreRequest>,
@@ -574,7 +574,7 @@ pub(super) mod tests {

let (_control_tx, control_rx) = tokio::sync::mpsc::channel(10);

- let mut task = MetricCollectionTask {
+ let mut task = RemoteMetricCollectionTask {
state,
metric_data_tx: tx,
control_message_rx: control_rx,
@@ -644,7 +644,7 @@ pub(super) mod tests {

let (_control_tx, control_rx) = tokio::sync::mpsc::channel(10);

- let mut task = MetricCollectionTask {
+ let mut task = RemoteMetricCollectionTask {
state,
metric_data_tx: tx,
control_message_rx: control_rx,
diff --git a/server/src/metric_collection/rrd_task.rs b/server/src/metric_collection/rrd_task.rs
index 48b6de9e..29137858 100644
--- a/server/src/metric_collection/rrd_task.rs
+++ b/server/src/metric_collection/rrd_task.rs
@@ -200,7 +200,7 @@ mod tests {
use pve_api_types::{ClusterMetrics, ClusterMetricsData};

use crate::{
- metric_collection::collection_task::tests::get_create_options,
+ metric_collection::remote_collection_task::tests::get_create_options,
test_support::temp::NamedTempDir,
};

diff --git a/server/src/metric_collection/state.rs b/server/src/metric_collection/state.rs
index 7f68843e..fd313c48 100644
--- a/server/src/metric_collection/state.rs
+++ b/server/src/metric_collection/state.rs
@@ -92,7 +92,7 @@ impl MetricCollectionState {

#[cfg(test)]
mod tests {
- use crate::metric_collection::collection_task::tests::get_create_options;
+ use crate::metric_collection::remote_collection_task::tests::get_create_options;
use crate::test_support::temp::NamedTempFile;

use super::*;
--
2.47.3