From 97a2736868bfcaac748b1b775c736e8d7e8d92d1 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Tue, 16 Aug 2022 19:10:11 -0400 Subject: [PATCH] add state metrics --- docs/tendermint-core/metrics.md | 2 ++ state/execution.go | 4 ++++ state/metrics.go | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/docs/tendermint-core/metrics.md b/docs/tendermint-core/metrics.md index 44aacc49f..f69313f95 100644 --- a/docs/tendermint-core/metrics.md +++ b/docs/tendermint-core/metrics.md @@ -60,6 +60,8 @@ The following metrics are available: | mempool_failed_txs | counter | | number of failed transactions | | mempool_recheck_times | counter | | number of transactions rechecked in the mempool | | state_block_processing_time | histogram | | time between BeginBlock and EndBlock in ms | +| state_consensus_param_updates | Counter | | number of consensus parameter updates returned by the application since process start | +| state_validator_set_updates | Counter | | number of validator set updates returned by the application since process start | ## Useful queries diff --git a/state/execution.go b/state/execution.go index fc34f8364..0cd53e5bb 100644 --- a/state/execution.go +++ b/state/execution.go @@ -233,6 +233,10 @@ func (blockExec *BlockExecutor) ApplyBlock( } if len(validatorUpdates) > 0 { blockExec.logger.Debug("updates to validators", "updates", types.ValidatorListString(validatorUpdates)) + blockExec.metrics.ValidatorSetUpdates.Add(1) + } + if abciResponses.EndBlock.ConsensusParamUpdates != nil { + blockExec.metrics.ConsensusParamUpdates.Add(1) } // Update the state with the block and responses. diff --git a/state/metrics.go b/state/metrics.go index 72712144f..6c238df76 100644 --- a/state/metrics.go +++ b/state/metrics.go @@ -16,4 +16,12 @@ const ( type Metrics struct { // Time between BeginBlock and EndBlock in ms. BlockProcessingTime metrics.Histogram `metrics_buckettype:"lin" metrics_bucketsizes:"1, 10, 10"` + + // ConsensusParamUpdates is the total number of times the application has + // udated the consensus params since process start. + ConsensusParamUpdates metrics.Counter + + // ValidatorSetUpdates is the total number of times the application has + // udated the validator set since process start. + ValidatorSetUpdates metrics.Counter }