core: add state height to prometheus metrics

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Roman Khimov 2020-06-24 14:47:08 +03:00 committed by Evgenii Stratonikov
parent 5ee3ecf381
commit e21c65c59f
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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))
}