github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/metrics/cleaner.go (about)

     1  package metrics
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/prometheus/client_golang/prometheus"
     7  	"github.com/prometheus/client_golang/prometheus/promauto"
     8  )
     9  
    10  type CleanerCollector struct {
    11  	gcDuration prometheus.Histogram
    12  }
    13  
    14  func NewCleanerCollector() *CleanerCollector {
    15  	cc := &CleanerCollector{
    16  		gcDuration: promauto.NewHistogram(prometheus.HistogramOpts{
    17  			Namespace: namespaceStorage,
    18  			Subsystem: subsystemBadger,
    19  			Name:      "garbage_collection_runtime_s",
    20  			Buckets:   []float64{1, 10, 60, 60 * 5, 60 * 15},
    21  			Help:      "the time spent on badger garbage collection",
    22  		}),
    23  	}
    24  	return cc
    25  }
    26  
    27  // RanGC records a successful run of the Badger garbage collector.
    28  func (cc *CleanerCollector) RanGC(duration time.Duration) {
    29  	cc.gcDuration.Observe(duration.Seconds())
    30  }