Only log multiple missed heartbeats as info (#763)
This commit is contained in:
parent
d8a9e93ff7
commit
ef594e1e02
|
@ -25,6 +25,14 @@ template heartbeat*(name: string, interval: Duration, body: untyped): untyped =
|
|||
nextHeartbeat += interval
|
||||
let now = Moment.now()
|
||||
if nextHeartbeat < now:
|
||||
info "Missed heartbeat", heartbeat = name, delay = now - nextHeartbeat
|
||||
nextHeartbeat = now + interval
|
||||
let
|
||||
delay = now - nextHeartbeat
|
||||
itv = interval
|
||||
if delay > itv:
|
||||
info "Missed multiple heartbeats", heartbeat = name,
|
||||
delay = delay, hinterval = itv
|
||||
else:
|
||||
debug "Missed heartbeat", heartbeat = name,
|
||||
delay = delay, hinterval = itv
|
||||
nextHeartbeat = now + itv
|
||||
await sleepAsync(nextHeartbeat - now)
|
||||
|
|
Loading…
Reference in New Issue