Skip to content

Commit

Permalink
feat: add basic rollapp Metrics for rollapp height and hub height (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItayLevyOfficial authored Jul 25, 2023
1 parent 479bfb8 commit 190379d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ func (m *Manager) SyncTargetLoop(ctx context.Context) {

// updateSyncParams updates the sync target and state index if necessary
func (m *Manager) updateSyncParams(ctx context.Context, endHeight uint64) {
rollappHubHeightGauge.Set(float64(endHeight))
m.logger.Info("Received new syncTarget", "syncTarget", endHeight)
atomic.StoreUint64(&m.syncTarget, endHeight)
atomic.StoreInt64(&m.lastSubmissionTime, time.Now().UnixNano())
Expand Down Expand Up @@ -707,6 +708,7 @@ func (m *Manager) produceBlock(ctx context.Context, allowEmpty bool) error {
}

m.logger.Info("block created", "height", newHeight, "num_tx", len(block.Data.Txs))
rollappHeightGauge.Set(float64(newHeight))

//TODO: move to separate function
lastSubmissionTime := atomic.LoadInt64(&m.lastSubmissionTime)
Expand Down
15 changes: 15 additions & 0 deletions block/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package block

import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

var rollappHeightGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "rollapp_height",
Help: "The height of the local rollapp",
})
var rollappHubHeightGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "rollapp_hub_height",
Help: "The latest height of the Rollapp that has been synced to the hub.",
})

0 comments on commit 190379d

Please sign in to comment.