[pdm-devel] [PATCH proxmox-datacenter-manager 17/25] metric collection: save time needed for collection run to RRD
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu Feb 13 12:53:14 CET 2025
On Tue, Feb 11, 2025 at 01:05:33PM +0100, Lukas Wagner wrote:
> For large setups, it might be useful to know how much time was needed to
> collect metrics for *all* remotes together, e.g. for making sure that
> the collection interval is not exceeded.
>
> Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
> ---
> .../src/metric_collection/collection_task.rs | 15 ++++++
> server/src/metric_collection/rrd_task.rs | 50 +++++++++++++++----
> 2 files changed, 56 insertions(+), 9 deletions(-)
>
> diff --git a/server/src/metric_collection/collection_task.rs b/server/src/metric_collection/collection_task.rs
> index 27a9987..501df9b 100644
> --- a/server/src/metric_collection/collection_task.rs
> +++ b/server/src/metric_collection/collection_task.rs
> @@ -22,6 +22,7 @@ use pdm_api_types::{
> };
> use pdm_config::metric_collection::COLLECTION_SETTINGS_TYPE;
>
> +use crate::metric_collection::rrd_task::CollectionStats;
> use crate::{connection, task_utils};
>
> use super::{
> @@ -97,6 +98,20 @@ impl MetricCollectionTask {
> if let Some(remotes) = Self::load_remote_config() {
> let to_fetch = remotes.order.as_slice();
> self.fetch_remotes(&remotes, to_fetch).await;
> +
> + let now = Instant::now();
> + self.fetch_remotes(&remotes, &remotes.order).await;
2 `fetch_remotes` calls now look a bit weird ;-)
should probably fold in some later change?
> + let elapsed = now.elapsed();
> +
> + if let Err(err) = self.metric_data_tx.send(
> + RrdStoreRequest::CollectionStats {
> + timestamp: proxmox_time::epoch_i64(),
> + stats: CollectionStats {
> + total_time: elapsed.as_secs_f64() * 1000.
> + }
> + }).await {
> + log::error!("could not send collection stats to rrd task: {err}");
> + }
> }
> }
>
More information about the pdm-devel
mailing list