mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
more metrics
This commit is contained in:
parent
3cdf3b670d
commit
489d9b9184
@ -13,6 +13,12 @@ type Metrics struct {
|
|||||||
MissingValidators metrics.Gauge
|
MissingValidators metrics.Gauge
|
||||||
// number of validators who tried to double sign
|
// number of validators who tried to double sign
|
||||||
ByzantineValidators metrics.Gauge
|
ByzantineValidators metrics.Gauge
|
||||||
|
// number of transactions
|
||||||
|
NumTxs metrics.Gauge
|
||||||
|
// total number of transactions
|
||||||
|
TotalTxs metrics.Counter
|
||||||
|
// size of the block
|
||||||
|
BlockSizeBytes metrics.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
// NopMetrics returns no-op Metrics.
|
// NopMetrics returns no-op Metrics.
|
||||||
@ -22,5 +28,8 @@ func NopMetrics() *Metrics {
|
|||||||
Validators: discard.NewGauge(),
|
Validators: discard.NewGauge(),
|
||||||
MissingValidators: discard.NewGauge(),
|
MissingValidators: discard.NewGauge(),
|
||||||
ByzantineValidators: discard.NewGauge(),
|
ByzantineValidators: discard.NewGauge(),
|
||||||
|
NumTxs: discard.NewGauge(),
|
||||||
|
TotalTxs: discard.NewCounter(),
|
||||||
|
BlockSizeBytes: discard.NewGauge(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1281,7 +1281,7 @@ func (cs *ConsensusState) finalizeCommit(height int64) {
|
|||||||
|
|
||||||
fail.Fail() // XXX
|
fail.Fail() // XXX
|
||||||
|
|
||||||
cs.recordValidatorMetrics(height, block)
|
cs.recordMetrics(height, block)
|
||||||
|
|
||||||
// NewHeightStep!
|
// NewHeightStep!
|
||||||
cs.updateToState(stateCopy)
|
cs.updateToState(stateCopy)
|
||||||
@ -1298,11 +1298,10 @@ func (cs *ConsensusState) finalizeCommit(height int64) {
|
|||||||
// * cs.StartTime is set to when we will start round0.
|
// * cs.StartTime is set to when we will start round0.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ConsensusState) recordValidatorMetrics(height int64, block *types.Block) {
|
func (cs *ConsensusState) recordMetrics(height int64, block *types.Block) {
|
||||||
heightStr := fmt.Sprintf("%d", height)
|
heightStr := fmt.Sprintf("%d", height)
|
||||||
|
|
||||||
cs.metrics.Validators.With("height", heightStr).Set(float64(cs.Validators.Size()))
|
cs.metrics.Validators.With("height", heightStr).Set(float64(cs.Validators.Size()))
|
||||||
|
|
||||||
missingValidators := 0
|
missingValidators := 0
|
||||||
for i := range cs.Validators.Validators {
|
for i := range cs.Validators.Validators {
|
||||||
var vote *types.Vote
|
var vote *types.Vote
|
||||||
@ -1314,8 +1313,12 @@ func (cs *ConsensusState) recordValidatorMetrics(height int64, block *types.Bloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.metrics.MissingValidators.With("height", heightStr).Set(float64(missingValidators))
|
cs.metrics.MissingValidators.With("height", heightStr).Set(float64(missingValidators))
|
||||||
|
|
||||||
cs.metrics.ByzantineValidators.With("height", heightStr).Set(float64(len(block.Evidence.Evidence)))
|
cs.metrics.ByzantineValidators.With("height", heightStr).Set(float64(len(block.Evidence.Evidence)))
|
||||||
|
|
||||||
|
cs.metrics.NumTxs.With("height", heightStr).Set(float64(block.NumTxs))
|
||||||
|
cs.metrics.TotalTxs.Add(float64(block.NumTxs))
|
||||||
|
|
||||||
|
cs.metrics.BlockSizeBytes.With("height", heightStr).Set(float64(block.Size()))
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
34
node/node.go
34
node/node.go
@ -252,6 +252,7 @@ func NewNode(config *cfg.Config,
|
|||||||
Name: "height",
|
Name: "height",
|
||||||
Help: "Height of the chain.",
|
Help: "Height of the chain.",
|
||||||
}, []string{}),
|
}, []string{}),
|
||||||
|
|
||||||
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
Subsystem: "consensus",
|
Subsystem: "consensus",
|
||||||
Name: "validators",
|
Name: "validators",
|
||||||
@ -267,6 +268,39 @@ func NewNode(config *cfg.Config,
|
|||||||
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, partitioned by height.",
|
||||||
}, []string{"height"}),
|
}, []string{"height"}),
|
||||||
|
|
||||||
|
// BlockInterval: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
|
// Subsystem: "consensus",
|
||||||
|
// Name: "block_interval",
|
||||||
|
// Help: "Time between this and the last block, partitioned by height.",
|
||||||
|
// }, []string{"height"}),
|
||||||
|
// BlockTime: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
|
// Subsystem: "consensus",
|
||||||
|
// Name: "time_to_create_block",
|
||||||
|
// Help: "Time to create a block (from sending a proposal to commit), partitioned by height",
|
||||||
|
// }, []string{"height"}),
|
||||||
|
// TimeBetweenBlocks: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
||||||
|
// Subsystem: "consensus",
|
||||||
|
// Name: "time_between_blocks",
|
||||||
|
// Help: "Time between committing the last block and (receiving/sending a proposal), partitioned by height",
|
||||||
|
// }, []string{"height"}),
|
||||||
|
|
||||||
|
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "num_txs",
|
||||||
|
Help: "Number of transactions, partitioned by height.",
|
||||||
|
}, []string{"height"}),
|
||||||
|
TotalTxs: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "total_txs",
|
||||||
|
Help: "Total number of transactions.",
|
||||||
|
}, []string{}),
|
||||||
|
|
||||||
|
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
|
||||||
|
Subsystem: "consensus",
|
||||||
|
Name: "block_size_bytes",
|
||||||
|
Help: "Size of the block, partitioned by height.",
|
||||||
|
}, []string{"height"}),
|
||||||
}
|
}
|
||||||
consensusState := cs.NewConsensusState(config.Consensus, state.Copy(),
|
consensusState := cs.NewConsensusState(config.Consensus, state.Copy(),
|
||||||
blockExec, blockStore, mempool, evidencePool, metrics)
|
blockExec, blockStore, mempool, evidencePool, metrics)
|
||||||
|
@ -135,6 +135,15 @@ func (b *Block) HashesTo(hash []byte) bool {
|
|||||||
return bytes.Equal(b.Hash(), hash)
|
return bytes.Equal(b.Hash(), hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Size returns size of the block in bytes.
|
||||||
|
func (b *Block) Size() int {
|
||||||
|
bz, err := cdc.MarshalBinaryBare(b)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return len(bz)
|
||||||
|
}
|
||||||
|
|
||||||
// String returns a string representation of the block
|
// String returns a string representation of the block
|
||||||
func (b *Block) String() string {
|
func (b *Block) String() string {
|
||||||
return b.StringIndented("")
|
return b.StringIndented("")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user