@@ -484,6 +484,24 @@ function updateCharts() {
484484 * This shows the impact of thread pool starvation on request processing time.
485485 */
486486function handleLatencyUpdate ( measurement ) {
487+ const timestamp = new Date ( measurement . timestamp ) ;
488+
489+ // Special handling for PAUSED state
490+ if ( measurement . isPaused ) {
491+ addLatencyToHistory ( timestamp , null , false , false ) ;
492+
493+ // Update display to show PAUSED status
494+ const currentEl = document . getElementById ( 'latencyCurrent' ) ;
495+ if ( currentEl ) {
496+ currentEl . textContent = "PAUSED" ;
497+ currentEl . className = 'latency-value' ;
498+ }
499+
500+ // Don't log anything for paused heartbeats
501+ updateLatencyChart ( ) ;
502+ return ;
503+ }
504+
487505 // Log significant latency events to the dashboard log
488506 if ( measurement . isError ) {
489507 logEvent ( 'error' , `⚠️ Health Probe Error: ${ measurement . errorMessage || 'Unknown error' } (${ formatLatency ( measurement . latencyMs ) } )` ) ;
@@ -499,7 +517,6 @@ function handleLatencyUpdate(measurement) {
499517 console . log ( 'Latency update:' , measurement ) ;
500518 }
501519
502- const timestamp = new Date ( measurement . timestamp ) ;
503520 const latencyMs = measurement . latencyMs ;
504521 const isTimeout = measurement . isTimeout ;
505522 const isError = measurement . isError ;
@@ -597,25 +614,31 @@ function addLatencyToHistory(timestamp, latencyMs, isTimeout, isError) {
597614function updateLatencyDisplay ( currentLatency , isTimeout , isError ) {
598615 const history = state . latencyHistory ;
599616
617+ // Ignore updates if the current value is null (paused)
618+ if ( currentLatency === null ) return ;
619+
600620 // Current latency with color coding (check if element exists)
601621 const currentEl = document . getElementById ( 'latencyCurrent' ) ;
602622 if ( currentEl ) {
603623 currentEl . textContent = formatLatency ( currentLatency ) ;
604624 currentEl . className = `latency-value ${ getLatencyClass ( currentLatency , isTimeout ) } ` ;
605625 }
606626
627+ // Filter out nulls for calculations
628+ const validValues = history . values . filter ( v => v !== null ) ;
629+
607630 // Calculate average
608631 const avgEl = document . getElementById ( 'latencyAverage' ) ;
609- if ( avgEl && history . values . length > 0 ) {
610- const avg = history . values . reduce ( ( a , b ) => a + b , 0 ) / history . values . length ;
632+ if ( avgEl && validValues . length > 0 ) {
633+ const avg = validValues . reduce ( ( a , b ) => a + b , 0 ) / validValues . length ;
611634 avgEl . textContent = formatLatency ( avg ) ;
612635 avgEl . className = `latency-value ${ getLatencyClass ( avg , false ) } ` ;
613636 }
614637
615638 // Calculate max
616639 const maxEl = document . getElementById ( 'latencyMax' ) ;
617- if ( maxEl && history . values . length > 0 ) {
618- const max = Math . max ( ...history . values ) ;
640+ if ( maxEl && validValues . length > 0 ) {
641+ const max = Math . max ( ...validValues ) ;
619642 maxEl . textContent = formatLatency ( max ) ;
620643
621644 // precise timeout check for max value could be complex,
@@ -679,6 +702,7 @@ function updateLatencyChart() {
679702
680703 // Map data points to colors based on latency
681704 const pointColors = history . values . map ( ( v , i ) => {
705+ if ( v === null ) return 'transparent' ; // Handle paused/null values
682706 if ( history . isTimeout [ i ] ) return '#d13438' ;
683707 if ( v > 1000 ) return '#d13438' ;
684708 if ( v > 150 ) return '#ffb900' ;
@@ -693,6 +717,8 @@ function updateLatencyChart() {
693717 borderColor : ctx => {
694718 const index = ctx . p0DataIndex ;
695719 const latency = history . values [ index ] ;
720+ if ( latency === null || history . values [ index + 1 ] === null ) return 'transparent' ; // Gap
721+
696722 const isTimeout = history . isTimeout [ index ] ;
697723 if ( isTimeout ) return '#d13438' ;
698724 if ( latency > 1000 ) return '#d13438' ;
0 commit comments