Skip to content

Commit

Permalink
add monitor block height mertics (#176)
Browse files Browse the repository at this point in the history
* add monitor block height mertics

* fix ut

---------

Co-authored-by: KamiD <44460798+KamiD@users.noreply.github.com>
Co-authored-by: chengzhinei <chengxue5yuan@163.com>
  • Loading branch information
3 people authored Jun 15, 2023
1 parent 8306798 commit 8391f54
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/tendermint/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func (blockExec *BlockExecutor) ApplyBlock(
now := time.Now().UnixNano()
blockExec.metrics.IntervalTime.Set(float64(now-blockExec.metrics.lastBlockTime) / 1e6)
blockExec.metrics.lastBlockTime = now
blockExec.metrics.CommittedHeight.Set(float64(block.Height))
}()

if err := blockExec.ValidateBlock(state, block); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions libs/tendermint/state/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type Metrics struct {
AbciTime metrics.Gauge
// Time during commiting app state
CommitTime metrics.Gauge

CommittedHeight metrics.Gauge
}

// PrometheusMetrics returns Metrics build using Prometheus client library.
Expand Down Expand Up @@ -64,6 +66,12 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
Name: "block_commit_time",
Help: "Time during commiting app state in ms.",
}, labels).With(labelsAndValues...),
CommittedHeight: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "monitor_block_height",
Help: "The block height.",
}, labels).With(labelsAndValues...),
}
}

Expand All @@ -75,5 +83,6 @@ func NopMetrics() *Metrics {
lastBlockTime: time.Now().UnixNano(),
AbciTime: discard.NewGauge(),
CommitTime: discard.NewGauge(),
CommittedHeight: discard.NewGauge(),
}
}

0 comments on commit 8391f54

Please sign in to comment.