Skip to content

Commit

Permalink
Log exports stats
Browse files Browse the repository at this point in the history
  • Loading branch information
otoolep committed Sep 5, 2021
1 parent 4a1dce1 commit a32fad6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bolt_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,31 @@ func (b *BoltStore) GetUint64(key []byte) (uint64, error) {
func (b *BoltStore) Sync() error {
return b.conn.Sync()
}

// Stats is the statistics for the BoltDB store.
type Stats struct {
// Freelist stats
FreePageN int `json:"num_free_pages"` // total number of free pages on the freelist
PendingPageN int `json:"num_pending_pages"` // total number of pending pages on the freelist
FreeAlloc int `json:"free_alloc"` // total bytes allocated in free pages
FreelistInuse int `json:"free_list_inuse"` // total bytes used by the freelist

// Transaction stats
TxN int `json:"num_tx_read"` // total number of started read transactions
OpenTxN int `json:"num_tx_open"` // number of currently open read transactions

//TxStats TxStats // global, ongoing stats.
}

// Stats returns the BoltStore statistics.
func (b *BoltStore) Stats() Stats {
stats := b.conn.Stats()
return Stats{
FreePageN: stats.FreePageN,
PendingPageN: stats.PendingPageN,
FreeAlloc: stats.FreeAlloc,
FreelistInuse: stats.FreelistInuse,
TxN: stats.TxN,
OpenTxN: stats.OpenTxN,
}
}

0 comments on commit a32fad6

Please sign in to comment.