mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-04 11:02:06 +00:00
This pull request adds an additional set of metrics targeted at providing more visibility into `abci++`.
The following set of metrics are added and exposed through the `metrics` endpoint:
```
tendermint_consensus_proposal_receive_count{chain_id="test-chain-IrF74Y",status="accepted"} 34
tendermint_consensus_proposal_create_count{chain_id="test-chain-IrF74Y"} 34
tendermint_consensus_vote_extension_receive_count{chain_id="test-chain-IrF74Y",status="accepted"} 34
tendermint_consensus_round_voting_power_percent{chain_id="test-chain-IrF74Y",vote_type="precommit"} 1
tendermint_consensus_round_voting_power_percent{chain_id="test-chain-IrF74Y",vote_type="prevote"} 1
tendermint_state_consensus_param_updates{chain_id="test-chain-IrF74Y"} 0
tendermint_state_validator_set_updates{chain_id="test-chain-IrF74Y"} 0
tendermint_consensus_late_votes{chain_id="test-chain-IrF74Y",vote_type="precommit"} 16
```
This pull request also updates the `metrics.md` file to include some metrics that were previously missed. My hope is to generate the `metrics.md` file with a future version of the tool being architected in #8479
72 lines
2.4 KiB
Go
72 lines
2.4 KiB
Go
package state
|
|
|
|
import (
|
|
"github.com/go-kit/kit/metrics"
|
|
"github.com/go-kit/kit/metrics/discard"
|
|
"github.com/go-kit/kit/metrics/prometheus"
|
|
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
const (
|
|
// MetricsSubsystem is a subsystem shared by all metrics exposed by this
|
|
// package.
|
|
MetricsSubsystem = "state"
|
|
)
|
|
|
|
// Metrics contains metrics exposed by this package.
|
|
type Metrics struct {
|
|
// Time between BeginBlock and EndBlock.
|
|
BlockProcessingTime metrics.Histogram
|
|
|
|
// 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
|
|
}
|
|
|
|
// PrometheusMetrics returns Metrics build using Prometheus client library.
|
|
// Optionally, labels can be provided along with their values ("foo",
|
|
// "fooValue").
|
|
func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
|
|
labels := []string{}
|
|
for i := 0; i < len(labelsAndValues); i += 2 {
|
|
labels = append(labels, labelsAndValues[i])
|
|
}
|
|
return &Metrics{
|
|
BlockProcessingTime: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "block_processing_time",
|
|
Help: "Time between BeginBlock and EndBlock in ms.",
|
|
Buckets: stdprometheus.LinearBuckets(1, 10, 10),
|
|
}, labels).With(labelsAndValues...),
|
|
ConsensusParamUpdates: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "consensus_param_updates",
|
|
Help: "The total number of times the application as updated the consensus " +
|
|
"parameters since process start.",
|
|
}, labels).With(labelsAndValues...),
|
|
|
|
ValidatorSetUpdates: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
|
|
Namespace: namespace,
|
|
Subsystem: MetricsSubsystem,
|
|
Name: "validator_set_updates",
|
|
Help: "The total number of times the application as updated the validator " +
|
|
"set since process start.",
|
|
}, labels).With(labelsAndValues...),
|
|
}
|
|
}
|
|
|
|
// NopMetrics returns no-op Metrics.
|
|
func NopMetrics() *Metrics {
|
|
return &Metrics{
|
|
BlockProcessingTime: discard.NewHistogram(),
|
|
ConsensusParamUpdates: discard.NewCounter(),
|
|
ValidatorSetUpdates: discard.NewCounter(),
|
|
}
|
|
}
|