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

feat: add DbLatestHeight metric to prometheus #88

Merged
merged 5 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Unreleased
- ([\#88](https://github.com/forbole/juno/pull/88)) Added `DbLatestHeight` metric to prometheus monitoring

## v4.0.0
### Changes
- Updated cosmos/cosmos-sdk to `v0.45.8`
Expand Down
14 changes: 14 additions & 0 deletions logging/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ var DbBlockCount = prometheus.NewGaugeVec(
[]string{"total_blocks_in_db"},
)

// DbLatestHeight represents the Telemetry counter used to track the last indexed height in the database
var DbLatestHeight = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "juno_db_latest_height",
Help: "Latest block height in the database.",
},
[]string{"db_latest_height"},
)

func init() {
err := prometheus.Register(StartHeight)
if err != nil {
Expand All @@ -70,4 +79,9 @@ func init() {
if err != nil {
panic(err)
}

err = prometheus.Register(DbLatestHeight)
if err != nil {
panic(err)
}
}
3 changes: 3 additions & 0 deletions parser/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,8 @@ func (w Worker) ExportTxs(txs []*types.Tx) error {
totalBlocks := w.db.GetTotalBlocks()
logging.DbBlockCount.WithLabelValues("total_blocks_in_db").Set(float64(totalBlocks))

dbLatestHeight, _ := w.db.GetLastBlockHeight()
huichiaotsou marked this conversation as resolved.
Show resolved Hide resolved
logging.DbLatestHeight.WithLabelValues("db_latest_height").Set(float64(dbLatestHeight))

return nil
}