mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-18 07:31:20 +00:00
add validators power gauges
This commit is contained in:
@ -4,22 +4,22 @@ import "github.com/go-kit/kit/metrics"
|
|||||||
import "github.com/go-kit/kit/metrics/discard"
|
import "github.com/go-kit/kit/metrics/discard"
|
||||||
|
|
||||||
// Metrics contains metrics exposed by this package.
|
// Metrics contains metrics exposed by this package.
|
||||||
|
// see MetricsProvider for descriptions.
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
// height of the chain
|
|
||||||
Height metrics.Counter
|
Height metrics.Counter
|
||||||
// number of validators who signed
|
|
||||||
Validators metrics.Gauge
|
Validators metrics.Gauge
|
||||||
// number of validators who did not sign
|
ValidatorsPower metrics.Gauge
|
||||||
MissingValidators metrics.Gauge
|
MissingValidators metrics.Gauge
|
||||||
// number of validators who tried to double sign
|
MissingValidatorsPower metrics.Gauge
|
||||||
ByzantineValidators metrics.Gauge
|
ByzantineValidators metrics.Gauge
|
||||||
// time between this and the last block
|
ByzantineValidatorsPower metrics.Gauge
|
||||||
|
|
||||||
BlockIntervalSeconds metrics.Histogram
|
BlockIntervalSeconds metrics.Histogram
|
||||||
// number of transactions
|
|
||||||
NumTxs metrics.Gauge
|
NumTxs metrics.Gauge
|
||||||
// total number of transactions
|
|
||||||
TotalTxs metrics.Counter
|
TotalTxs metrics.Counter
|
||||||
// size of the block
|
|
||||||
BlockSizeBytes metrics.Gauge
|
BlockSizeBytes metrics.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1300,18 +1300,29 @@ func (cs *ConsensusState) finalizeCommit(height int64) {
|
|||||||
|
|
||||||
func (cs *ConsensusState) recordMetrics(height int64, block *types.Block) {
|
func (cs *ConsensusState) recordMetrics(height int64, block *types.Block) {
|
||||||
cs.metrics.Validators.Set(float64(cs.Validators.Size()))
|
cs.metrics.Validators.Set(float64(cs.Validators.Size()))
|
||||||
|
cs.metrics.ValidatorsPower.Set(float64(cs.Validators.TotalVotingPower()))
|
||||||
missingValidators := 0
|
missingValidators := 0
|
||||||
for i := range cs.Validators.Validators {
|
missingValidatorsPower := int64(0)
|
||||||
|
for i, val := range cs.Validators.Validators {
|
||||||
var vote *types.Vote
|
var vote *types.Vote
|
||||||
if i < len(block.LastCommit.Precommits) {
|
if i < len(block.LastCommit.Precommits) {
|
||||||
vote = block.LastCommit.Precommits[i]
|
vote = block.LastCommit.Precommits[i]
|
||||||
}
|
}
|
||||||
if vote == nil {
|
if vote == nil {
|
||||||
missingValidators++
|
missingValidators++
|
||||||
|
missingValidatorsPower += val.VotingPower
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.metrics.MissingValidators.Set(float64(missingValidators))
|
cs.metrics.MissingValidators.Set(float64(missingValidators))
|
||||||
|
cs.metrics.MissingValidatorsPower.Set(float64(missingValidatorsPower))
|
||||||
cs.metrics.ByzantineValidators.Set(float64(len(block.Evidence.Evidence)))
|
cs.metrics.ByzantineValidators.Set(float64(len(block.Evidence.Evidence)))
|
||||||
|
byzantineValidatorsPower := int64(0)
|
||||||
|
for _, ev := range block.Evidence.Evidence {
|
||||||
|
if _, val := cs.Validators.GetByAddress(ev.Address()); val != nil {
|
||||||
|
byzantineValidatorsPower += val.VotingPower
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cs.metrics.ByzantineValidatorsPower.Set(float64(byzantineValidatorsPower))
|
||||||
|
|
||||||
if height > 1 {
|
if height > 1 {
|
||||||
lastBlockMeta := cs.blockStore.LoadBlockMeta(height - 1)
|
lastBlockMeta := cs.blockStore.LoadBlockMeta(height - 1)
|
||||||
|
27
node/node.go
27
node/node.go
@ -106,30 +106,45 @@ func DefaultMetricsProvider() *cs.Metrics {
|
|||||||
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
Name: "validators",
|
Name: "validators",
|
||||||
Help: "Number of validators who signed, partitioned by height.",
|
Help: "Number of validators who signed.",
|
||||||
|
}, []string{}),
|
||||||
|
ValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "validators_power",
|
||||||
|
Help: "Total power of all validators.",
|
||||||
}, []string{}),
|
}, []string{}),
|
||||||
MissingValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
MissingValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
Name: "missing_validators",
|
Name: "missing_validators",
|
||||||
Help: "Number of validators who did not sign, partitioned by height.",
|
Help: "Number of validators who did not sign.",
|
||||||
|
}, []string{}),
|
||||||
|
MissingValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "missing_validators_power",
|
||||||
|
Help: "Total power of the missing validators.",
|
||||||
}, []string{}),
|
}, []string{}),
|
||||||
ByzantineValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
ByzantineValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
Name: "byzantine_validators",
|
Name: "byzantine_validators",
|
||||||
Help: "Number of validators who tried to double sign, partitioned by height.",
|
Help: "Number of validators who tried to double sign.",
|
||||||
|
}, []string{}),
|
||||||
|
ByzantineValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "byzantine_validators_power",
|
||||||
|
Help: "Total power of the byzantine validators.",
|
||||||
}, []string{}),
|
}, []string{}),
|
||||||
|
|
||||||
BlockIntervalSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
BlockIntervalSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
Name: "block_interval_seconds",
|
Name: "block_interval_seconds",
|
||||||
Help: "Time between this and the last block, partitioned by height.",
|
Help: "Time between this and the last block.",
|
||||||
Buckets: []float64{1, 2.5, 5, 10, 60},
|
Buckets: []float64{1, 2.5, 5, 10, 60},
|
||||||
}, []string{}),
|
}, []string{}),
|
||||||
|
|
||||||
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
Name: "num_txs",
|
Name: "num_txs",
|
||||||
Help: "Number of transactions, partitioned by height.",
|
Help: "Number of transactions.",
|
||||||
}, []string{}),
|
}, []string{}),
|
||||||
TotalTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
TotalTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
@ -140,7 +155,7 @@ func DefaultMetricsProvider() *cs.Metrics {
|
|||||||
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
Name: "block_size_bytes",
|
Name: "block_size_bytes",
|
||||||
Help: "Size of the block, partitioned by height.",
|
Help: "Size of the block.",
|
||||||
}, []string{}),
|
}, []string{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user