storagenode/piecestore/usedserials: add monkit metric for serials that are randomly deleted

This will give storagenode operators a better idea of whether the memory
allocated to the usedserials store is sufficient.

Change-Id: I5c30f2e39473a573f43409511ad9e2e32680479c
This commit is contained in:
Moby von Briesen 2020-06-09 16:58:48 -04:00
parent a7211badc2
commit 0b109c32e4
2 changed files with 5 additions and 0 deletions

View File

@ -98,3 +98,4 @@ storj.io/storj/satellite/satellitedb."unknown_audit_reputation_beta" FloatVal
storj.io/storj/storage/filestore."open_file_in_trash" Meter
storj.io/storj/storagenode/contact."satellite_contact_request" Meter
storj.io/storj/storagenode/gracefulexit."satellite_gracefulexit_request" Meter
storj.io/storj/storagenode/piecestore/usedserials."delete_random_serial" Meter

View File

@ -10,6 +10,7 @@ import (
"sync"
"time"
"github.com/spacemonkeygo/monkit/v3"
"github.com/zeebo/errs"
"storj.io/common/memory"
@ -21,6 +22,8 @@ var (
ErrSerials = errs.Class("used serials store error")
// ErrSerialAlreadyExists defines an error class for duplicate usedserials.
ErrSerialAlreadyExists = errs.Class("used serial already exists in store")
mon = monkit.Package()
)
const (
@ -198,6 +201,7 @@ func (table *Table) Count() int {
// deleteRandomSerial deletes a random item.
// It expects the mutex to be locked before being called.
func (table *Table) deleteRandomSerial() error {
mon.Meter("delete_random_serial").Mark(1) //locked
for _, satMap := range table.serials {
for expirationHour, serialList := range satMap {
if len(serialList.partialSerials) > 0 {