Skip to content

Commit

Permalink
fix prometheus metric names
Browse files Browse the repository at this point in the history
  • Loading branch information
nibty committed Mar 14, 2024
1 parent e529a4e commit 9fa3525
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions integration/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (ds *StoreWithMetrics) meter(refresh time.Duration) {
continue
}
var nDiskSize int64
if n, err := fmt.Sscanf(diskSize, "Size(B):%d", &nDiskSize); n != 1 || err != nil {
if n, err := fmt.Sscanf(diskSize, "%d", &nDiskSize); n != 1 || err != nil {
ds.log.Error("Bad syntax of disk size entry", "size", diskSize)
merr = err
continue
Expand Down Expand Up @@ -146,16 +146,16 @@ func (db *DBProducerWithMetrics) OpenDB(name string) (kvdb.Store, error) {
return nil, err
}
dm := WrapStoreWithMetrics(ds)
// disk size gauge should be meter separatly for each db name; otherwise,
// the last db siae metric will overwrite all the previoius one
dm.diskSizeGauge = metrics.GetOrRegisterGauge("opera/chaindata/"+name+"/disk/size", nil)
if strings.HasPrefix(name, "gossip-") || strings.HasPrefix(name, "lachesis-") {
// disk size gauge should be metered separately for each db name; otherwise,
// the last db size metric will overwrite all the previous ones
dm.diskSizeGauge = metrics.GetOrRegisterGauge("opera/chaindata/"+strings.ReplaceAll(name, "-", "_")+"/disk/size", nil)
if strings.HasPrefix(name, "gossip-") || strings.HasPrefix(name, "lachesis-") || strings.HasPrefix(name, "epoch-") {
name = "epochs"
}
logger := log.New("database", name)
dm.log = logger
dm.diskReadMeter = metrics.GetOrRegisterMeter("opera/chaindata/"+name+"/disk/read", nil)
dm.diskWriteMeter = metrics.GetOrRegisterMeter("opera/chaindata/"+name+"/disk/write", nil)
dm.diskReadMeter = metrics.GetOrRegisterMeter("opera/chaindata/"+strings.ReplaceAll(name, "-", "_")+"/disk/read", nil)
dm.diskWriteMeter = metrics.GetOrRegisterMeter("opera/chaindata/"+strings.ReplaceAll(name, "-", "_")+"/disk/write", nil)

// Start up the metrics gathering and return
go dm.meter(metricsGatheringInterval)
Expand Down

0 comments on commit 9fa3525

Please sign in to comment.