Skip to content

Commit

Permalink
feat: add database block count to prometheus to improve alert monitor…
Browse files Browse the repository at this point in the history
…ing (#74)

Fixes [BDU-542](https://forbole.atlassian.net/browse/BDU-542)

- [x] Targeted PR against correct branch.
- [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Wrote unit tests.
- [x] Re-reviewed `Files changed` in the Github PR explorer.
  • Loading branch information
MonikaCat authored and RiccardoM committed Nov 23, 2022
1 parent 7b03805 commit dbb2133
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions database/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT DO NOTHING`
return err
}

// GetTotalBlocks implements database.Database
func (db *Database) GetTotalBlocks() int64 {
var blockCount int64
err := db.Sql.QueryRow(`SELECT count(*) FROM block;`).Scan(&blockCount)
if err != nil {
return 0
}

return blockCount
}

// SaveTx implements database.Database
func (db *Database) SaveTx(tx *types.Tx) error {
var partitionID int64
Expand Down

0 comments on commit dbb2133

Please sign in to comment.