@@ -370,12 +370,6 @@ impl Lambda {
370370 let uptime = uptime_data_end - uptime_data_offset;
371371 let total_idle_time = cpu_data_end. total_idle_time_ms - cpu_data_offset. total_idle_time_ms ;
372372
373- // Change in uptime should be positive and greater than total idle time across all cores
374- if uptime <= 0.0 || ( uptime * num_cores) < total_idle_time {
375- debug ! ( "Invalid uptime, skipping CPU utilization metrics" ) ;
376- return ;
377- }
378-
379373 let mut max_idle_time = 0.0 ;
380374 let mut min_idle_time = f64:: MAX ;
381375 let now = std:: time:: UNIX_EPOCH
@@ -389,8 +383,6 @@ impl Lambda {
389383 cpu_data_offset. individual_cpu_idle_times . get ( cpu_name)
390384 {
391385 let idle_time = cpu_idle_time - cpu_idle_time_offset;
392- let idle_time = idle_time. max ( 0.0 ) ; // Ensure idle time is non-negative
393-
394386 if idle_time < min_idle_time {
395387 min_idle_time = idle_time;
396388 }
@@ -402,15 +394,15 @@ impl Lambda {
402394
403395 // Maximally utilized CPU is the one with the least time spent in the idle process
404396 // Multiply by 100 to report as percentage
405- let cpu_max_utilization = ( ( uptime - min_idle_time) . max ( 0.0 ) / uptime) * 100.0 ;
397+ let cpu_max_utilization = ( ( uptime - min_idle_time) / uptime) * 100.0 ;
406398
407399 // Minimally utilized CPU is the one with the most time spent in the idle process
408400 // Multiply by 100 to report as percentage
409- let cpu_min_utilization = ( ( uptime - max_idle_time) . max ( 0.0 ) / uptime) * 100.0 ;
401+ let cpu_min_utilization = ( ( uptime - max_idle_time) / uptime) * 100.0 ;
410402
411403 // CPU total utilization is the proportion of total non-idle time to the total uptime across all cores
412404 let cpu_total_utilization_decimal =
413- ( ( uptime * num_cores) - total_idle_time) . max ( 0.0 ) / ( uptime * num_cores) ;
405+ ( ( uptime * num_cores) - total_idle_time) / ( uptime * num_cores) ;
414406 // Multiply by 100 to report as percentage
415407 let cpu_total_utilization_pct = cpu_total_utilization_decimal * 100.0 ;
416408 // Multiply by num_cores to report in terms of cores
0 commit comments