From 34435390014b59ec397b4c49363080134f70c401 Mon Sep 17 00:00:00 2001 From: Tony Solomonik Date: Fri, 6 Dec 2024 20:13:22 +0200 Subject: [PATCH] workflow: Log workflow execution time --- src/workflow/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/workflow/mod.rs b/src/workflow/mod.rs index 6af282d..f8b7165 100644 --- a/src/workflow/mod.rs +++ b/src/workflow/mod.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{sync::Arc, time::Instant}; use async_stream::stream; use color_eyre::eyre::{bail, Context, Result}; @@ -8,7 +8,7 @@ use serde_json::to_string; use summarize::{summarize_stream, Summarize}; use tokio::{spawn, sync::mpsc, task::JoinHandle}; use topn::topn_stream; -use tracing::debug; +use tracing::{debug, info, instrument}; use vrl::core::Value; use crate::{ @@ -236,8 +236,9 @@ impl WorkflowStep { } } +#[instrument(skip_all)] async fn execute_tasks(mut tasks: WorkflowTasks) -> Result<()> { - debug!("Waiting for workflow tasks"); + let start = Instant::now(); while let Some(join_result) = tasks.next().await { let result = join_result?; @@ -249,7 +250,8 @@ async fn execute_tasks(mut tasks: WorkflowTasks) -> Result<()> { } } - debug!("Workflow tasks done"); + let duration = start.elapsed(); + info!(elapsed_time = ?duration, "Workflow execution time"); Ok(()) }