parent
940b2e1c03
commit
c6ae83d1aa
|
|
@ -18,16 +18,22 @@ use log::{error, info, warn};
|
||||||
|
|
||||||
pub async fn get_metrics_from_monitoring(duration: usize, delay: usize) -> anyhow::Result<()> {
|
pub async fn get_metrics_from_monitoring(duration: usize, delay: usize) -> anyhow::Result<()> {
|
||||||
let timer = tokio::time::Instant::now();
|
let timer = tokio::time::Instant::now();
|
||||||
loop {
|
'outer: loop {
|
||||||
if duration != 0 && timer.elapsed() >= tokio::time::Duration::from_secs(duration as u64) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
let mut a = MonitoringImporter::new().await;
|
let mut a = MonitoringImporter::new().await;
|
||||||
a.start_session().await?;
|
a.start_session().await?;
|
||||||
let vec = a.get_metrics_list().await?;
|
'inner: loop {
|
||||||
let _ = a.get_measure_info(Arc::new(vec)).await;
|
if duration != 0 && timer.elapsed() >= tokio::time::Duration::from_secs(duration as u64) {
|
||||||
a.close_session().await?;
|
break 'outer;
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(delay as u64)).await
|
}
|
||||||
|
let vec = a.get_metrics_list().await.unwrap_or_else(|_| vec![]);
|
||||||
|
if vec.is_empty() {
|
||||||
|
warn!("Session dropped, creating new ...");
|
||||||
|
break 'inner;
|
||||||
|
}
|
||||||
|
let _ = a.get_measure_info(Arc::new(vec)).await;
|
||||||
|
// a.close_session().await?;
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(delay as u64)).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue