add metric for nextActionWait (#2399)

* add metric for nextActionWait

* use toFloatSeconds
This commit is contained in:
tersec 2021-03-12 09:46:26 +00:00 committed by GitHub
parent c47d636cb3
commit 5ebf36f54d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -9,7 +9,7 @@
import
chronicles, chronos,
../spec/[crypto, datatypes, digest],
../spec/[crypto, datatypes],
../consensus_object_pools/[blockchain_dag, attestation_pool]
# TODO: Move to "consensus_object_pools" folder

View File

@ -8,7 +8,7 @@
{.push raises: [Defect].}
import
std/[math, tables],
std/tables,
stew/results,
chronicles, chronos, metrics,
../spec/[crypto, datatypes, digest],

View File

@ -67,6 +67,9 @@ declareGauge finalization_delay,
declareGauge ticks_delay,
"How long does to take to run the onSecond loop"
declareGauge next_action_wait,
"Seconds until the next attestation will be sent"
logScope: topics = "beacnde"
func enrForkIdFromState(state: BeaconState): ENRForkID =
@ -928,7 +931,8 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} =
horizonSlot = compute_start_slot_at_epoch(
node.attestationSubnets.lastCalculatedAttestationEpoch + 1) - 1
nextAttestationSlot = node.getNextAttestation(slot)
nextActionWait = saturate(fromNow(node.beaconClock, nextAttestationSlot))
nextActionWaitTime =
saturate(fromNow(node.beaconClock, nextAttestationSlot))
horizonDistance = saturate(fromNow(node.beaconClock, horizonSlot))
info "Slot end",
@ -944,9 +948,12 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} =
if nextAttestationSlot == FAR_FUTURE_SLOT:
"n/a"
else:
shortLog(nextActionWait),
shortLog(nextActionWaitTime),
lookaheadTime = shortLog(horizonDistance)
if nextAttestationSlot != FAR_FUTURE_SLOT:
next_action_wait.set(nextActionWaitTime.toFloatSeconds)
node.updateGossipStatus(slot)
proc onSlotStart(