storj/satellite/accounting/bucketstats.go
Michał Niewrzał 18ef3d3881 satellite/accounting: add metrics for total pending objects
We don't have metric to track how many pending objects we have in the
system. This change is using tally objects loop to collect pending
objects per bucket and at the end its combining all buckets values
into single metric for all pending objects in a system.

Change-Id: Iac7a6bfb48854f7e70127d275ea8fdd60c4eb8b7
2022-06-06 12:04:46 +00:00

42 lines
838 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package accounting
import (
"storj.io/storj/satellite/metabase"
)
// BucketTally contains information about aggregate data stored in a bucket.
type BucketTally struct {
metabase.BucketLocation
ObjectCount int64
PendingObjectCount int64
TotalSegments int64
TotalBytes int64
MetadataSize int64
}
// Combine aggregates all the tallies.
func (s *BucketTally) Combine(o *BucketTally) {
s.ObjectCount += o.ObjectCount
s.PendingObjectCount += o.PendingObjectCount
s.TotalSegments += o.TotalSegments
s.TotalBytes += o.TotalBytes
}
// Segments returns total number of segments.
func (s *BucketTally) Segments() int64 {
return s.TotalSegments
}
// Bytes returns total bytes.
func (s *BucketTally) Bytes() int64 {
return s.TotalBytes
}