mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 20:21:56 +00:00
validator metrics
This commit is contained in:
@@ -7,11 +7,20 @@ import "github.com/go-kit/kit/metrics/discard"
|
||||
type Metrics struct {
|
||||
// height of the chain
|
||||
Height metrics.Counter
|
||||
// number of validators who signed
|
||||
Validators metrics.Gauge
|
||||
// number of validators who did not sign
|
||||
MissingValidators metrics.Gauge
|
||||
// number of validators who tried to double sign
|
||||
ByzantineValidators metrics.Gauge
|
||||
}
|
||||
|
||||
// NopMetrics returns no-op Metrics.
|
||||
func NopMetrics() *Metrics {
|
||||
return &Metrics{
|
||||
Height: discard.NewCounter(),
|
||||
Height: discard.NewCounter(),
|
||||
Validators: discard.NewGauge(),
|
||||
MissingValidators: discard.NewGauge(),
|
||||
ByzantineValidators: discard.NewGauge(),
|
||||
}
|
||||
}
|
||||
|
@@ -1281,6 +1281,8 @@ func (cs *ConsensusState) finalizeCommit(height int64) {
|
||||
|
||||
fail.Fail() // XXX
|
||||
|
||||
cs.recordValidatorMetrics(height, block)
|
||||
|
||||
// NewHeightStep!
|
||||
cs.updateToState(stateCopy)
|
||||
|
||||
@@ -1296,6 +1298,26 @@ func (cs *ConsensusState) finalizeCommit(height int64) {
|
||||
// * cs.StartTime is set to when we will start round0.
|
||||
}
|
||||
|
||||
func (cs *ConsensusState) recordValidatorMetrics(height int64, block *types.Block) {
|
||||
heightStr := fmt.Sprintf("%d", height)
|
||||
|
||||
cs.metrics.Validators.With("height", heightStr).Set(float64(cs.Validators.Size()))
|
||||
|
||||
missingValidators := 0
|
||||
for i := range cs.Validators.Validators {
|
||||
var vote *types.Vote
|
||||
if i < len(block.LastCommit.Precommits) {
|
||||
vote = block.LastCommit.Precommits[i]
|
||||
}
|
||||
if vote == nil {
|
||||
missingValidators++
|
||||
}
|
||||
}
|
||||
cs.metrics.MissingValidators.With("height", heightStr).Set(float64(missingValidators))
|
||||
|
||||
cs.metrics.ByzantineValidators.With("height", heightStr).Set(float64(len(block.Evidence.Evidence)))
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
func (cs *ConsensusState) defaultSetProposal(proposal *types.Proposal) error {
|
||||
|
Reference in New Issue
Block a user