Add metrics per keys for next scheduled attestation and proposal (#8583)

* Add metrics per keys for next scheduled attestation and proposal

* Found a better place where to update the counters

* Wrap with emitAccountMetrics flag
This commit is contained in:
Benoit Perroud
2021-03-09 22:13:11 +01:00
committed by GitHub
parent 72be10f9a5
commit 9980ca3b7e
2 changed files with 30 additions and 2 deletions

View File

@@ -172,6 +172,28 @@ var (
"pubkey",
},
)
// ValidatorNextAttestationSlotGaugeVec used to track validator statuses by public key.
ValidatorNextAttestationSlotGaugeVec = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "validator",
Name: "next_attestation_slot",
Help: "validator next scheduled attestation slot",
},
[]string{
"pubkey",
},
)
// ValidatorNextProposalSlotGaugeVec used to track validator statuses by public key.
ValidatorNextProposalSlotGaugeVec = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "validator",
Name: "next_proposal_slot",
Help: "validator next scheduled proposal slot",
},
[]string{
"pubkey",
},
)
)
// LogValidatorGainsAndLosses logs important metrics related to this validator client's

View File

@@ -634,9 +634,9 @@ func (v *validator) logDuties(slot types.Slot, duties []*ethpb.DutiesResponse_Du
slotOffset := slot - (slot % params.BeaconConfig().SlotsPerEpoch)
var totalAttestingKeys uint64
for _, duty := range duties {
validatorNotTruncatedKey := fmt.Sprintf("%#x", duty.PublicKey)
if v.emitAccountMetrics {
fmtKey := fmt.Sprintf("%#x", duty.PublicKey)
ValidatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(duty.Status))
ValidatorStatusesGaugeVec.WithLabelValues(validatorNotTruncatedKey).Set(float64(duty.Status))
}
// Only interested in validators who are attesting/proposing.
@@ -652,6 +652,9 @@ func (v *validator) logDuties(slot types.Slot, duties []*ethpb.DutiesResponse_Du
} else {
attesterKeys[duty.AttesterSlot-slotOffset] = append(attesterKeys[duty.AttesterSlot-slotOffset], validatorKey)
totalAttestingKeys++
if v.emitAccountMetrics {
ValidatorNextAttestationSlotGaugeVec.WithLabelValues(validatorNotTruncatedKey).Set(float64(duty.AttesterSlot))
}
}
for _, proposerSlot := range duty.ProposerSlots {
@@ -661,6 +664,9 @@ func (v *validator) logDuties(slot types.Slot, duties []*ethpb.DutiesResponse_Du
} else {
proposerKeys[proposerIndex] = validatorKey
}
if v.emitAccountMetrics {
ValidatorNextProposalSlotGaugeVec.WithLabelValues(validatorNotTruncatedKey).Set(float64(proposerSlot))
}
}
}
for i := types.Slot(0); i < params.BeaconConfig().SlotsPerEpoch; i++ {