fix namespace

This commit is contained in:
i-norden 2021-10-24 18:36:49 -05:00
parent 3d3e68c0ae
commit f207284e3a
3 changed files with 24 additions and 15 deletions

View File

@ -23,7 +23,7 @@ import (
)
const (
namespace = "eth-statediff-service"
namespace = "eth_statediff_service"
subsystem = "connections"
)

View File

@ -38,43 +38,52 @@ var (
tTxCommit prometheus.Histogram
)
const (
LOADED_HEIGHT = "loaded_height"
PROCESSED_HEIGHT = "processed_height"
T_BLOCK_LOAD = "t_block_load"
T_BLOCK_PROCESSING = "t_block_processing"
T_STATE_PROCESSING = "t_state_processing"
T_POSTGRES_TX_COMMIT = "t_postgres_tx_commit"
)
// Init module initialization
func Init() {
metrics = true
lastLoadedHeight = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "loaded_height",
Name: LOADED_HEIGHT,
Help: "The last block that was loaded for processing",
})
lastProcessedHeight = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "processed_height",
Name: PROCESSED_HEIGHT,
Help: "The last block that was processed",
})
tBlockLoad = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: statsSubsystem,
Name: "t_block_load",
Name: T_BLOCK_LOAD,
Help: "Block loading time",
})
tBlockProcessing = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: statsSubsystem,
Name: "t_block_processing",
Name: T_BLOCK_PROCESSING,
Help: "Block (header, uncles, txs, rcts, tx trie, rct trie) processing time",
})
tStateProcessing = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: statsSubsystem,
Name: "t_state_processing",
Name: T_STATE_PROCESSING,
Help: "State (state trie, storage tries, and code) processing time",
})
tTxCommit = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Subsystem: statsSubsystem,
Name: "t_postgres_tx_commit",
Name: T_POSTGRES_TX_COMMIT,
Help: "Postgres tx commit time",
})
}
@ -107,13 +116,13 @@ func SetTimeMetric(name string, t time.Duration) {
}
tAsF64 := t.Seconds()
switch name {
case "t_block_load":
case T_BLOCK_LOAD:
tBlockLoad.Observe(tAsF64)
case "t_block_processing":
case T_BLOCK_PROCESSING:
tBlockProcessing.Observe(tAsF64)
case "t_state_processing":
case T_STATE_PROCESSING:
tStateProcessing.Observe(tAsF64)
case "t_postgres_tx_commit":
case T_POSTGRES_TX_COMMIT:
tTxCommit.Observe(tAsF64)
}
}

View File

@ -309,7 +309,7 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p
}
height := block.Number().Int64()
prom.SetLastLoadedHeight(height)
prom.SetTimeMetric("t_block_load", time.Now().Sub(t))
prom.SetTimeMetric(prom.T_BLOCK_LOAD, time.Now().Sub(t))
t = time.Now()
tx, err := sds.indexer.PushBlock(block, receipts, totalDifficulty)
if err != nil {
@ -322,16 +322,16 @@ func (sds *Service) writeStateDiff(block *types.Block, parentRoot common.Hash, p
codeOutput := func(c sdtypes.CodeAndCodeHash) error {
return sds.indexer.PushCodeAndCodeHash(tx, c)
}
prom.SetTimeMetric("t_block_processing", time.Now().Sub(t))
prom.SetTimeMetric(prom.T_BLOCK_PROCESSING, time.Now().Sub(t))
t = time.Now()
err = sds.Builder.WriteStateDiffObject(sd.StateRoots{
NewStateRoot: block.Root(),
OldStateRoot: parentRoot,
}, params, output, codeOutput)
prom.SetTimeMetric("t_state_processing", time.Now().Sub(t))
prom.SetTimeMetric(prom.T_STATE_PROCESSING, time.Now().Sub(t))
t = time.Now()
err = tx.Close(err)
prom.SetLastProcessedHeight(height)
prom.SetTimeMetric("t_postgres_tx_commit", time.Now().Sub(t))
prom.SetTimeMetric(prom.T_POSTGRES_TX_COMMIT, time.Now().Sub(t))
return err
}