From c04eb371ccd805e8d0d0a03b4ef654c7a8131ccd Mon Sep 17 00:00:00 2001 From: Pyra <92104930+pyranota@users.noreply.github.com> Date: Mon, 19 Jan 2026 16:48:50 +0100 Subject: [PATCH] feat: move job metrics from ee to ce (#7608) * open source job metrics Signed-off-by: pyranota * fix Signed-off-by: pyranota * update Signed-off-by: pyranota --------- Signed-off-by: pyranota --- backend/windmill-worker/src/handle_child.rs | 47 ++++++++----------- .../components/MemoryFootprintViewer.svelte | 8 +--- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/backend/windmill-worker/src/handle_child.rs b/backend/windmill-worker/src/handle_child.rs index 18e053116a..8de0899c04 100644 --- a/backend/windmill-worker/src/handle_child.rs +++ b/backend/windmill-worker/src/handle_child.rs @@ -36,7 +36,6 @@ use std::{io, panic, time::Duration}; use tracing::{trace_span, Instrument}; use uuid::Uuid; -#[cfg(feature = "enterprise")] use windmill_common::job_metrics; #[cfg(target_os = "linux")] @@ -696,7 +695,6 @@ where let mut i = 0; - #[cfg(feature = "enterprise")] let mut memory_metric_id: Result = Err(Error::NotFound("not yet initialized".to_string())); @@ -731,32 +729,26 @@ where let update_job_row = i == 2 || (!*SLOW_LOGS && (i < 20 || (i < 120 && i % 5 == 0) || i % 10 == 0)) || i % 20 == 0; - if update_job_row { - #[cfg(feature = "enterprise")] - { - if job_id != Uuid::nil() { - if let Connection::Sql(ref db) = conn { - // tracking metric starting at i >= 2 b/c first point it useless and we don't want to track metric for super fast jobs - if i == 2 { - memory_metric_id = job_metrics::register_metric_for_job( - &db, - w_id.to_string(), - job_id, - "memory_kb".to_string(), - job_metrics::MetricKind::TimeseriesInt, - Some("Job Memory Footprint (kB)".to_string()), - ) - .await; - } - if let Ok(ref metric_id) = memory_metric_id { - if let Err(err) = job_metrics::record_metric(&db, w_id.to_string(), job_id, metric_id.to_owned(), job_metrics::MetricNumericValue::Integer(current_mem)).await { - tracing::error!("Unable to save memory stat for job {} in workspace {}. Error was: {:?}", job_id, w_id, err); - } + if update_job_row && job_id != Uuid::nil() { + if let Connection::Sql(ref db) = conn { + // tracking metric starting at i >= 2 b/c first point it useless and we don't want to track metric for super fast jobs + if i == 2 { + memory_metric_id = job_metrics::register_metric_for_job( + &db, + w_id.to_string(), + job_id, + "memory_kb".to_string(), + job_metrics::MetricKind::TimeseriesInt, + Some("Job Memory Footprint (kB)".to_string()), + ) + .await; + } + if let Ok(ref metric_id) = memory_metric_id { + if let Err(err) = job_metrics::record_metric(&db, w_id.to_string(), job_id, metric_id.to_owned(), job_metrics::MetricNumericValue::Integer(current_mem)).await { + tracing::error!("Unable to save memory stat for job {} in workspace {}. Error was: {:?}", job_id, w_id, err); } } } - } - if job_id != Uuid::nil() { if matches!(conn, Connection::Http(_)) { if i % 4 != 0 { // only ping every 4th time (2s) on http agent mode @@ -764,8 +756,8 @@ where } } let ping_job_status = ping_job_status(&conn, &job_id, Some(*mem_peak), if current_mem > 0 { Some(current_mem) } else { None }).await.unwrap_or_else(|e| { - tracing::error!("Unable to ping job status for job {job_id}. Error was: {:?}", e); - PingJobStatusResponse { + tracing::error!("Unable to ping job status for job {job_id}. Error was: {:?}", e); + PingJobStatusResponse { canceled_by: None, canceled_reason: None, already_completed: false, @@ -782,7 +774,6 @@ where break } } - } }, ); } diff --git a/frontend/src/lib/components/MemoryFootprintViewer.svelte b/frontend/src/lib/components/MemoryFootprintViewer.svelte index afcdfb82a4..66da99e6e6 100644 --- a/frontend/src/lib/components/MemoryFootprintViewer.svelte +++ b/frontend/src/lib/components/MemoryFootprintViewer.svelte @@ -1,7 +1,7 @@
- {#if !$enterpriseLicense} - - Job metrics are only available on Windmill Enterprise Edition. - - {:else if (jobMemoryStats?.length ?? 0) === 0} + {#if (jobMemoryStats?.length ?? 0) === 0} No data points available for this job. Metrics are recorded only for jobs running for more than 500ms.