[prometheus] update validator metrics from node module

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3459/head
Leo Chen 4 years ago
parent c28f6c7ca4
commit ddc0f7f02f
  1. 6
      consensus/consensus_v2.go
  2. 7
      consensus/metrics.go
  3. 8
      consensus/validator.go
  4. 4
      node/node_handler.go

@ -113,8 +113,10 @@ func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, msg *msg_pb
}
func (consensus *Consensus) finalCommit() {
numCommits := consensus.Decider.SignersCount(quorum.Commit)
consensus.getLogger().Info().
Int64("NumCommits", consensus.Decider.SignersCount(quorum.Commit)).
Int64("NumCommits", numCommits).
Msg("[finalCommit] Finalizing Consensus")
beforeCatchupNum := consensus.blockNum
@ -214,7 +216,7 @@ func (consensus *Consensus) finalCommit() {
Msg("HOORAY!!!!!!! CONSENSUS REACHED!!!!!!!")
ConsensusCounterVec.With(prometheus.Labels{"consensus": "hooray"}).Inc()
ConsensusGaugeVec.With(prometheus.Labels{"consensus": "block_num"}).Set(float64(block.NumberU64()))
ConsensusGaugeVec.With(prometheus.Labels{"consensus": "num_commits"}).Set(float64(consensus.Decider.SignersCount(quorum.Commit)))
ConsensusGaugeVec.With(prometheus.Labels{"consensus": "num_commits"}).Set(float64(numCommits))
// If still the leader, send commit sig/bitmap to finish the new block proposal,
// else, the block proposal will timeout by itself.

@ -67,3 +67,10 @@ var (
},
)
)
func (consensus *Consensus) UpdateValidatorMetrics(numSig float64, blockNum float64) {
ConsensusCounterVec.With(prometheus.Labels{"consensus": "bingo"}).Inc()
ConsensusGaugeVec.With(prometheus.Labels{"consensus": "signatures"}).Set(numSig)
ConsensusCounterVec.With(prometheus.Labels{"consensus": "signatures"}).Add(numSig)
ConsensusGaugeVec.With(prometheus.Labels{"consensus": "block_num"}).Set(blockNum)
}

@ -13,7 +13,6 @@ import (
"github.com/harmony-one/harmony/consensus/signature"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/p2p"
"github.com/prometheus/client_golang/prometheus"
)
func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
@ -294,13 +293,6 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) {
}
}
ConsensusCounterVec.With(prometheus.Labels{"consensus": "bingo"}).Inc()
numSig := float64(consensus.NumSignaturesIncludedInBlock(blockObj))
ConsensusGaugeVec.With(prometheus.Labels{"consensus": "signatures"}).Set(numSig)
ConsensusCounterVec.With(prometheus.Labels{"consensus": "signatures"}).Add(numSig)
ConsensusGaugeVec.With(prometheus.Labels{"consensus": "block_num"}).Set(float64(blockObj.NumberU64()))
initBn := consensus.blockNum
consensus.tryCatchup()
if recvMsg.BlockNum > consensus.blockNum {

@ -348,6 +348,10 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block) error {
Int("numStakingTxns", len(newBlock.StakingTransactions())).
Uint32("numSignatures", node.Consensus.NumSignaturesIncludedInBlock(newBlock)).
Msg("BINGO !!! Reached Consensus")
numSig := float64(node.Consensus.NumSignaturesIncludedInBlock(newBlock))
node.Consensus.UpdateValidatorMetrics(numSig, float64(newBlock.NumberU64()))
// 1% of the validator also need to do broadcasting
rand.Seed(time.Now().UTC().UnixNano())
rnd := rand.Intn(100)

Loading…
Cancel
Save