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 duration metrics of gauge type #256

Merged
merged 1 commit into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions consensus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ type Metrics struct {
DurationCommitCommitting metrics.Histogram
DurationCommitRechecking metrics.Histogram
DurationWaitingForNewRound metrics.Histogram

DurationGaugeProposal metrics.Gauge
DurationGaugePrevote metrics.Gauge
DurationGaugePrecommit metrics.Gauge
DurationGaugeCommitExecuting metrics.Gauge
DurationGaugeCommitCommitting metrics.Gauge
DurationGaugeCommitRechecking metrics.Gauge
DurationGaugeWaitingForNewRound metrics.Gauge
}

// PrometheusMetrics returns Metrics build using Prometheus client library.
Expand Down Expand Up @@ -267,6 +275,48 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
Help: "Duration of waiting for next new round",
Buckets: stdprometheus.LinearBuckets(100, 100, 10),
}, labels).With(labelsAndValues...),
DurationGaugeProposal: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_gauge_proposal",
Help: "Duration of proposal step",
}, labels).With(labelsAndValues...),
DurationGaugePrevote: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_gauge_prevote",
Help: "Duration of prevote step",
}, labels).With(labelsAndValues...),
DurationGaugePrecommit: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_gauge_precommit",
Help: "Duration of precommit step",
}, labels).With(labelsAndValues...),
DurationGaugeCommitExecuting: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_gauge_commit_executing",
Help: "Duration of executing block txs",
}, labels).With(labelsAndValues...),
DurationGaugeCommitCommitting: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_gauge_commit_committing",
Help: "Duration of committing updated state",
}, labels).With(labelsAndValues...),
DurationGaugeCommitRechecking: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_gauge_commit_rechecking",
Help: "Duration of rechecking mempool txs",
}, labels).With(labelsAndValues...),
DurationGaugeWaitingForNewRound: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "duration_gauge_waiting_for_new_round",
Help: "Duration of waiting for next new round",
}, labels).With(labelsAndValues...),
}
}

Expand Down Expand Up @@ -308,5 +358,13 @@ func NopMetrics() *Metrics {
DurationCommitCommitting: discard.NewHistogram(),
DurationCommitRechecking: discard.NewHistogram(),
DurationWaitingForNewRound: discard.NewHistogram(),

DurationGaugeProposal: discard.NewGauge(),
DurationGaugePrevote: discard.NewGauge(),
DurationGaugePrecommit: discard.NewGauge(),
DurationGaugeCommitExecuting: discard.NewGauge(),
DurationGaugeCommitCommitting: discard.NewGauge(),
DurationGaugeCommitRechecking: discard.NewGauge(),
DurationGaugeWaitingForNewRound: discard.NewGauge(),
}
}
8 changes: 8 additions & 0 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,14 @@ func (cs *State) recordMetrics(height int64, block *types.Block) {
cs.metrics.DurationCommitCommitting.Observe(cs.stepTimes.CommitCommitting.GetDuration())
cs.metrics.DurationCommitRechecking.Observe(cs.stepTimes.CommitRechecking.GetDuration())
cs.metrics.DurationWaitingForNewRound.Observe(cs.stepTimes.WaitingForNewRound.GetDuration())

cs.metrics.DurationGaugeProposal.Set(cs.stepTimes.Proposal.GetDuration())
cs.metrics.DurationGaugePrevote.Set(cs.stepTimes.Prevote.GetDuration())
cs.metrics.DurationGaugePrecommit.Set(cs.stepTimes.Precommit.GetDuration())
cs.metrics.DurationGaugeCommitExecuting.Set(cs.stepTimes.CommitExecuting.GetDuration())
cs.metrics.DurationGaugeCommitCommitting.Set(cs.stepTimes.CommitCommitting.GetDuration())
cs.metrics.DurationGaugeCommitRechecking.Set(cs.stepTimes.CommitRechecking.GetDuration())
cs.metrics.DurationGaugeWaitingForNewRound.Set(cs.stepTimes.WaitingForNewRound.GetDuration())
}

//-----------------------------------------------------------------------------
Expand Down