From 66b66b966b9c0d850540f339f2531caa2526d591 Mon Sep 17 00:00:00 2001 From: prplV Date: Tue, 27 May 2025 02:43:21 -0400 Subject: [PATCH] adding tracing --- crates/api-grub/src/jitter.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/api-grub/src/jitter.rs b/crates/api-grub/src/jitter.rs index 19899c4..a06c3d8 100644 --- a/crates/api-grub/src/jitter.rs +++ b/crates/api-grub/src/jitter.rs @@ -3,7 +3,7 @@ use integr_structs::api::v3::{PrometheusMetricsExtended, MetricOutputExtended}; use std::sync::Arc; use reqwest::Client; use lazy_static::lazy_static; -use tracing::{error, info, warn}; +use tracing::{error, info, trace, warn}; use std::pin::Pin; use serde_json::{Value, from_str}; use crate::export::Exporter; @@ -55,6 +55,7 @@ impl Requester { }) } pub async fn get_conferences(&self) -> anyhow::Result { + trace!("getting conferences list from API"); let url = format!("{}{}", self.base, *CONFERENCES_ENDPOINT); let req = self.client.get(url) .timeout(tokio::time::Duration::from_secs(10)) @@ -64,6 +65,7 @@ impl Requester { Ok(from_str(&resp?.text().await?)?) } pub async fn get_conferences_from_value(conferences: Value) -> anyhow::Result { + trace!("extracting conferences list"); let mut hashset = Conferences::new(); match conferences.get("data") { None => return Err(anyhow::Error::msg("Invalid JSON format: no `data` field")), @@ -100,6 +102,7 @@ impl Requester { Ok(hashset) } pub async fn get_users_jitter_by_conference(&self, conferences : Conferences) -> anyhow::Result { + trace!("getting users list for each conference from API ..."); let mut output = OutputConferences::new(); for conf in conferences { let url = format!("{}{}{}", self.base, *USERS_ENDPOINT, &conf.1); @@ -127,6 +130,7 @@ impl Requester { fn across_participants(conf: &Value) -> impl Stream> + '_ { + trace!("fetching participants for conf and going across ..."); let participants_iter = conf .get("data") .and_then(|data| data.get("participants")) @@ -143,6 +147,7 @@ impl Requester { } async fn gather_futures(parts: Arc, conf_id: Arc, conf_desc: Arc, targets: Vec<(&str, &str)>) -> Vec> { + trace!("extracting {} measures for current participant in current conference {} ...", targets.len(), conf_id); let mut futures: Vec> + Send>>> = Vec::new(); for (target, description) in targets { futures.push(Box::pin(extract_from_participant( @@ -182,6 +187,7 @@ async fn extract_total_anon_participants(conferences : Arc) -> Value { // GET participants/{conference_id} data.participants[].isAnonymous async fn extract_from_participant(participant : Arc, target: &str, conf_id: Arc, conf_desc: Arc, description: &str) -> Option { + trace!("extracting `{}` measure for current participant ...", target); if let Some(value) = participant.get("params") .and_then(|params| params.get(target)) { let name = participant.get("watermark").unwrap_or_else(|| &Value::Null).as_str().unwrap_or_else(|| "unknown");