Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add some metrics measuring consensus step duration #126

Merged
merged 13 commits into from
Oct 21, 2020
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

### FEATURES:
- [init command] [\#125](https://github.com/line/tendermint/pull/125) Add an option selecting private key type to init, testnet commands
- [consensus] [\#126](https://github.com/line/tendermint/pull/126) Add some metrics measuring duration of each consensus steps

### IMPROVEMENTS:

Expand Down
2 changes: 1 addition & 1 deletion cmd/tendermint/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewInitCmd() *cobra.Command {
}

func AddInitFlags(cmd *cobra.Command) {
cmd.Flags().String("priv-key-type", config.PrivKeyType,
cmd.Flags().String("priv_key_type", config.PrivKeyType,
"Specify validator's private key type (ed25519 | composite)")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/tendermint/commands/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func init() {
"P2P Port")
TestnetFilesCmd.Flags().BoolVar(&randomMonikers, "random-monikers", false,
"Randomize the moniker for each generated node")
TestnetFilesCmd.Flags().StringVar(&privKeyType, "priv-key-type", privval.PrevKeyTypeEd25519,
TestnetFilesCmd.Flags().StringVar(&privKeyType, "priv_key_type", privval.PrevKeyTypeEd25519,
"Specify validator's private key type (ed25519 | composite)")
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ type BaseConfig struct { //nolint: maligned
FilterPeers bool `mapstructure:"filter_peers"` // false

// Specify validator's private key type
PrivKeyType string `mapstructure:"priv-key-type"`
PrivKeyType string `mapstructure:"priv_key_type"`
}

// DefaultBaseConfig returns a default base configuration for a Tendermint node
Expand Down
115 changes: 115 additions & 0 deletions consensus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ type Metrics struct {

// Number of blockparts transmitted by peer.
BlockParts metrics.Counter

// Number of blocks that are we couldn't receive
MissingProposal metrics.Gauge

// Number of rounds turned over.
RoundFailures metrics.Histogram

// Execution time profiling of each step
ProposalCreating metrics.Histogram
ProposalWaiting metrics.Histogram
ProposalVerifying metrics.Histogram
ProposalBlockReceiving metrics.Histogram
PrevoteBlockVerifying metrics.Histogram
PrevoteReceiving metrics.Histogram
PrecommitBlockVerifying metrics.Histogram
PrecommitReceiving metrics.Histogram
CommitBlockVerifying metrics.Histogram
CommitBlockApplying metrics.Histogram
}

// PrometheusMetrics returns Metrics build using Prometheus client library.
Expand Down Expand Up @@ -197,6 +215,89 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
Name: "block_parts",
Help: "Number of blockparts transmitted by peer.",
}, append(labels, "peer_id")).With(labelsAndValues...),
MissingProposal: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "missing_proposal",
Help: "Number of blocks we couldn't receive",
}, labels).With(labelsAndValues...),
RoundFailures: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "round_failures",
Help: "Number of rounds failed on consensus",
Buckets: stdprometheus.LinearBuckets(0, 1, 5),
}, labels).With(labelsAndValues...),
ProposalCreating: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_proposal_creating",
Help: "Duration of creating proposal and block",
Buckets: stdprometheus.LinearBuckets(100, 100, 10),
}, labels).With(labelsAndValues...),
ProposalWaiting: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_proposal_waiting",
Help: "Duration between enterNewRound and receiving proposal",
Buckets: stdprometheus.LinearBuckets(100, 100, 10),
}, labels).With(labelsAndValues...),
ProposalVerifying: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_proposal_verifying",
Help: "Duration of ValidBlock",
Buckets: stdprometheus.LinearBuckets(50, 50, 10),
}, labels).With(labelsAndValues...),
ProposalBlockReceiving: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_proposal_block_receiving",
Help: "Duration of receiving all proposal block parts",
Buckets: stdprometheus.LinearBuckets(100, 100, 10),
}, labels).With(labelsAndValues...),
PrevoteBlockVerifying: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_prevote_block_verifying",
Help: "Duration of ValidBlock in prevote",
Buckets: stdprometheus.LinearBuckets(50, 50, 10),
}, labels).With(labelsAndValues...),
PrevoteReceiving: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_prevote_receiving",
Help: "Duration of receiving 2/3+ prevotes",
Buckets: stdprometheus.LinearBuckets(100, 100, 10),
}, labels).With(labelsAndValues...),
PrecommitBlockVerifying: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_precommit_block_verifying",
Help: "Duration of ValidBlock in precommit",
Buckets: stdprometheus.LinearBuckets(50, 50, 10),
}, labels).With(labelsAndValues...),
PrecommitReceiving: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_precommit_receiving",
Help: "Duration of receiving 2/3+ precommits",
Buckets: stdprometheus.LinearBuckets(100, 100, 10),
}, labels).With(labelsAndValues...),
CommitBlockVerifying: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_commit_block_verifying",
Help: "Duration of ValidBlock in commit",
Buckets: stdprometheus.LinearBuckets(50, 50, 10),
}, labels).With(labelsAndValues...),
CommitBlockApplying: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_commit_block_applying",
Help: "Duration of applying block",
Buckets: stdprometheus.LinearBuckets(100, 100, 10),
}, labels).With(labelsAndValues...),
}
}

Expand Down Expand Up @@ -228,5 +329,19 @@ func NopMetrics() *Metrics {
CommittedHeight: discard.NewGauge(),
FastSyncing: discard.NewGauge(),
BlockParts: discard.NewCounter(),

MissingProposal: discard.NewGauge(),
RoundFailures: discard.NewHistogram(),

ProposalCreating: discard.NewHistogram(),
ProposalWaiting: discard.NewHistogram(),
ProposalVerifying: discard.NewHistogram(),
ProposalBlockReceiving: discard.NewHistogram(),
PrevoteBlockVerifying: discard.NewHistogram(),
PrevoteReceiving: discard.NewHistogram(),
PrecommitBlockVerifying: discard.NewHistogram(),
PrecommitReceiving: discard.NewHistogram(),
CommitBlockVerifying: discard.NewHistogram(),
CommitBlockApplying: discard.NewHistogram(),
}
}
Loading