Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add monitor block height metrics #3176

Merged
merged 4 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/tendermint/blockchain/v0/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ FOR_LOOP:
// TODO: same thing for app - but we would need a way to
// get the hash without persisting the state
var err error

bcR.curState, _, err = bcR.blockExec.ApplyBlockWithTrace(bcR.curState, firstID, first) // rpc
if err != nil {
// TODO This is bad, are we zombie?
Expand Down
2 changes: 2 additions & 0 deletions libs/tendermint/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func (blockExec *BlockExecutor) ApplyBlock(
f, t := PprofStart()
defer PprofEnd(int(block.Height), f, t)
}

trc := trace.NewTracer(trace.ApplyBlock)
trc.EnableSummary()
trc.SetWorkloadStatistic(trace.GetApplyBlockWorkloadSttistic())
Expand All @@ -224,6 +225,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(),
}
}