health check logs

This commit is contained in:
wphan
2023-12-02 14:13:02 -08:00
parent 12281198e5
commit 032121de27

View File

@@ -165,12 +165,16 @@ const handleHealthCheck = (
// healthy if slot has advanced since the last check // healthy if slot has advanced since the last check
const lastSlotReceived = slotSource.getSlot(); const lastSlotReceived = slotSource.getSlot();
const inGracePeriod =
Date.now() - lastTimeHealthy <= healthCheckGracePeriod;
lastHealthCheckState = lastSlotReceived > lastHealthCheckSlot; lastHealthCheckState = lastSlotReceived > lastHealthCheckSlot;
if (!lastHealthCheckState) { if (!lastHealthCheckState) {
logger.error( logger.error(
`Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, timeSinceLastCheck: ${ `Unhealthy: lastSlot: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, timeSinceLastCheck: ${
Date.now() - lastHealthCheckPerformed Date.now() - lastHealthCheckPerformed
} ms` } ms, sinceLastTimeHealthy: ${
Date.now() - lastTimeHealthy
} ms, inGracePeriod: ${inGracePeriod}`
); );
} else { } else {
lastTimeHealthy = Date.now(); lastTimeHealthy = Date.now();
@@ -179,10 +183,7 @@ const handleHealthCheck = (
lastHealthCheckSlot = lastSlotReceived; lastHealthCheckSlot = lastSlotReceived;
lastHealthCheckPerformed = Date.now(); lastHealthCheckPerformed = Date.now();
if ( if (!lastHealthCheckState && !inGracePeriod) {
!lastHealthCheckState &&
Date.now() - lastTimeHealthy > healthCheckGracePeriod
) {
healthStatus = HEALTH_STATUS.UnhealthySlotSubscriber; healthStatus = HEALTH_STATUS.UnhealthySlotSubscriber;
res.writeHead(500); res.writeHead(500);