github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/metrics/badger.go (about) 1 package metrics 2 3 import ( 4 // _ "github.com/dgraph-io/badger/v2" // TODO this might be needed for servers just testing metrics 5 "fmt" 6 7 "github.com/prometheus/client_golang/prometheus" 8 "github.com/prometheus/client_golang/prometheus/collectors" 9 ) 10 11 func RegisterBadgerMetrics() error { 12 expvarCol := collectors.NewExpvarCollector(map[string]*prometheus.Desc{ 13 "badger_disk_reads_total": prometheus.NewDesc( 14 fmt.Sprintf("%s_%s_disk_reads_total", namespaceStorage, subsystemBadger), "cumulative number of reads", nil, nil), 15 "badger_disk_writes_total": prometheus.NewDesc( 16 fmt.Sprintf("%s_%s_disk_writes_total", namespaceStorage, subsystemBadger), "cumulative number of writes", nil, nil), 17 "badger_read_bytes": prometheus.NewDesc( 18 fmt.Sprintf("%s_%s_read_bytes", namespaceStorage, subsystemBadger), "cumulative number of bytes read", nil, nil), 19 "badger_written_bytes": prometheus.NewDesc( 20 fmt.Sprintf("%s_%s_written_bytes", namespaceStorage, subsystemBadger), "cumulative number of bytes written", nil, nil), 21 "badger_gets_total": prometheus.NewDesc( 22 fmt.Sprintf("%s_%s_gets_total", namespaceStorage, subsystemBadger), "number of gets", nil, nil), 23 "badger_memtable_gets_total": prometheus.NewDesc( 24 fmt.Sprintf("%s_%s_memtable_gets_total", namespaceStorage, subsystemBadger), "number of memtable gets", nil, nil), 25 "badger_puts_total": prometheus.NewDesc( 26 fmt.Sprintf("%s_%s_puts_total", namespaceStorage, subsystemBadger), "number of puts", nil, nil), 27 // NOTE: variable exists, but not used in badger yet 28 //"badger_blocked_puts_total": prometheus.NewDesc( 29 // fmt.Sprintf("%s_%s_blocked_puts_total", namespaceStorage, subsystemBadger), "number of blocked puts", nil, nil), 30 "badger_pending_writes_total": prometheus.NewDesc( 31 fmt.Sprintf("%s_%s_badger_pending_writes_total", namespaceStorage, subsystemBadger), "tracks the number of pending writes", []string{"path"}, nil), 32 "badger_lsm_bloom_hits_total": prometheus.NewDesc( 33 fmt.Sprintf("%s_%s_lsm_bloom_hits_total", namespaceStorage, subsystemBadger), "number of LSM bloom hits", []string{"level"}, nil), 34 "badger_lsm_level_gets_total": prometheus.NewDesc( 35 fmt.Sprintf("%s_%s_lsm_level_gets_total", namespaceStorage, subsystemBadger), "number of LSM gets", []string{"level"}, nil), 36 "badger_lsm_size_bytes": prometheus.NewDesc( 37 fmt.Sprintf("%s_%s_lsm_size_bytes", namespaceStorage, subsystemBadger), "size of the LSM in bytes", []string{"path"}, nil), 38 "badger_vlog_size_bytes": prometheus.NewDesc( 39 fmt.Sprintf("%s_%s_vlog_size_bytes", namespaceStorage, subsystemBadger), "size of the value log in bytes", []string{"path"}, nil), 40 }) 41 42 err := prometheus.Register(expvarCol) 43 if err != nil { 44 return fmt.Errorf("failed to register badger metrics: %w", err) 45 } 46 return nil 47 }