From e21c65c59fd2941ed9c2d469a3e9a00251fbd295 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 24 Jun 2020 14:47:08 +0300 Subject: [PATCH] core: add state height to prometheus metrics Signed-off-by: Evgenii Stratonikov --- pkg/core/blockchain.go | 1 + pkg/core/prometheus.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 08e959bfb..055008e86 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1272,6 +1272,7 @@ func (bc *Blockchain) updateStateHeight(newHeight uint32) error { if err != nil { return errors.WithMessage(err, "can't get current state root height") } else if newHeight == h+1 { + updateStateHeightMetric(newHeight) return bc.dao.PutCurrentStateRootHeight(h + 1) } return nil diff --git a/pkg/core/prometheus.go b/pkg/core/prometheus.go index b81fb847d..c849e3459 100644 --- a/pkg/core/prometheus.go +++ b/pkg/core/prometheus.go @@ -30,6 +30,14 @@ var ( Namespace: "neogo", }, ) + //stateHeight prometheus metric. + stateHeight = prometheus.NewGauge( + prometheus.GaugeOpts{ + Help: "Current verified state height", + Name: "current_state_height", + Namespace: "neogo", + }, + ) ) func init() { @@ -51,3 +59,7 @@ func updateHeaderHeightMetric(hHeight int) { func updateBlockHeightMetric(bHeight uint32) { blockHeight.Set(float64(bHeight)) } + +func updateStateHeightMetric(sHeight uint32) { + stateHeight.Set(float64(sHeight)) +}