From 0cb50c05fc4ef24a109be368526a935c4b479894 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 15 Jun 2018 14:45:21 +0400 Subject: [PATCH] add rounds metric --- consensus/metrics.go | 1 + consensus/state.go | 1 + node/node.go | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/consensus/metrics.go b/consensus/metrics.go index 064e5be5c..169c2fd76 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -7,6 +7,7 @@ import "github.com/go-kit/kit/metrics/discard" // see MetricsProvider for descriptions. type Metrics struct { Height metrics.Counter + Rounds metrics.Gauge Validators metrics.Gauge ValidatorsPower metrics.Gauge diff --git a/consensus/state.go b/consensus/state.go index 61e01a9be..f078663dd 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -697,6 +697,7 @@ func (cs *ConsensusState) enterNewRound(height int64, round int) { } logger.Info(cmn.Fmt("enterNewRound(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step)) + cs.metrics.Rounds.Set(float64(round)) // Increment validators if necessary validators := cs.Validators diff --git a/node/node.go b/node/node.go index 79862088a..5630df6c0 100644 --- a/node/node.go +++ b/node/node.go @@ -102,6 +102,11 @@ func DefaultMetricsProvider() *cs.Metrics { Name: "height", Help: "Height of the chain.", }, []string{}), + Rounds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ + Subsystem: "consensus", + Name: "rounds", + Help: "Number of rounds.", + }, []string{}), Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Subsystem: "consensus",