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 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Unreleased

### Changes
- ([\#74](https://github.com/forbole/juno/pull/74)) Applied `GetMissingHeights()` in `enqueueMissingBlocks()` & in `parse blocks missing` cmd
- ([\#88](https://github.com/forbole/juno/pull/88)) Added `juno_db_latest_height` metric to prometheus monitoring

## v4.0.0
### Changes
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)
}
}
6 changes: 6 additions & 0 deletions parser/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,11 @@ func (w Worker) ExportTxs(txs []*types.Tx) error {
totalBlocks := w.db.GetTotalBlocks()
logging.DbBlockCount.WithLabelValues("total_blocks_in_db").Set(float64(totalBlocks))

dbLatestHeight, err := w.db.GetLastBlockHeight()
if err != nil {
return err
}
logging.DbLatestHeight.WithLabelValues("db_latest_height").Set(float64(dbLatestHeight))

return nil
}