swarm/storage: added metrics for db entry count (#17589)

This commit is contained in:
Elad
2018-09-06 12:11:38 +02:00
committed by Balint Gabor
parent 4c15ffffdd
commit 580145e96d
2 changed files with 25 additions and 20 deletions

View File

@ -48,6 +48,10 @@ const (
maxGCitems = 5000 // max number of items to be gc'd per call to collectGarbage()
)
var (
dbEntryCount = metrics.NewRegisteredCounter("ldbstore.entryCnt", nil)
)
var (
keyIndex = byte(0)
keyOldData = byte(1)
@ -495,6 +499,7 @@ func (s *LDBStore) delete(idx uint64, idxKey []byte, po uint8) {
batch.Delete(idxKey)
batch.Delete(getDataKey(idx, po))
s.entryCnt--
dbEntryCount.Dec(1)
s.bucketCnt[po]--
cntKey := make([]byte, 2)
cntKey[0] = keyDistanceCnt
@ -566,6 +571,7 @@ func (s *LDBStore) doPut(chunk *Chunk, index *dpaDBIndex, po uint8) {
index.Idx = s.dataIdx
s.bucketCnt[po] = s.dataIdx
s.entryCnt++
dbEntryCount.Inc(1)
s.dataIdx++
cntKey := make([]byte, 2)