From 267e90c972e15aedc63e71aa07bd95ca682c9ea5 Mon Sep 17 00:00:00 2001 From: prplV Date: Wed, 5 Mar 2025 16:56:46 +0300 Subject: [PATCH] added monitoring doc comms --- crates/api-grub/src/monitoring.rs | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crates/api-grub/src/monitoring.rs b/crates/api-grub/src/monitoring.rs index aef585e..564eb71 100644 --- a/crates/api-grub/src/monitoring.rs +++ b/crates/api-grub/src/monitoring.rs @@ -13,6 +13,31 @@ use integr_structs::api::v3::{MetricOutputExtended, PrometheusMetricsExtended}; use log::{error, info, warn}; use std::collections::HashMap; +/// # Fn `get_metrics_from_monitoring` +/// +/// A function to init pulling and exporting metrics mechanism +/// from CM to Exporter. It spawns async tasks to get measures +/// and their values and then extract needed info to export +/// +/// ### Dev-Info : +/// +/// *input* : duration and delay as `usize` (in secs) +/// +/// *output* : `anyhow::Result<()>` +/// +/// *initiator* : fn `main` +/// +/// *managing* : runtime of N async tasks (N - count of chunks) +/// +/// # Example +/// +/// ``` +/// use api-grub::monitoring::get_metrics_from_monitoring; +/// +/// // exec func without time restriction but with delay in 5 secs +/// assert_eq!(get_metrics_from_monitoring(0, 5).await, Ok(())); +/// ``` +/// pub async fn get_metrics_from_monitoring(duration: usize, delay: usize) -> anyhow::Result<()> { let timer = tokio::time::Instant::now(); 'outer: loop { @@ -34,6 +59,23 @@ pub async fn get_metrics_from_monitoring(duration: usize, delay: usize) -> anyho Ok(()) } +/// An entity which handle CM creds +/// +/// Used to capture measures and there values, to preprocess all measures to +/// relevant Exporter's structure +/// +/// # Example: +/// +/// ``` +/// use api-grub::monitoring::MonitoringImporter; +/// +/// let mut a = MonitoringImporter::new().await; +/// a.start_session().await?; +/// let vec = Arc::new(a.get_metrics_list().await.unwrap_or_else(|_| vec![])); +/// +/// assert_eq!(a.get_measure_info(vec.clone()).await, Ok(())); +/// ``` +/// #[derive(Debug, Clone)] pub struct MonitoringImporter { ip : String,