Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freemanzMrojo committed Jan 10, 2025
1 parent 5505c91 commit 79d7c06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 8 additions & 6 deletions cmd/thor/node/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import (
)

var (
metricBlockProcessedCount = metrics.LazyLoadCounterVec("block_processed_count", []string{"type", "success"})
metricBlockProcessedTxs = metrics.LazyLoadGaugeVec("block_processed_tx_gauge", []string{"type"})
metricBlockProcessedGas = metrics.LazyLoadGaugeVec("block_processed_gas_gauge", []string{"type"})
metricBlockProcessedDuration = metrics.LazyLoadHistogram("block_processed_duration_ms", metrics.Bucket10s)
metricChainForkCount = metrics.LazyLoadCounter("chain_fork_count")
metricChainForkSize = metrics.LazyLoadGauge("chain_fork_gauge")
metricBlockProcessedCount = metrics.LazyLoadCounterVec("block_processed_count", []string{"type", "success"})
metricBlockProcessedTxs = metrics.LazyLoadGaugeVec("block_processed_tx_gauge", []string{"type"})
metricBlockProcessedGas = metrics.LazyLoadGaugeVec("block_processed_gas_gauge", []string{"type"})
metricBlockProcessedDuration = metrics.LazyLoadHistogram("block_processed_duration_ms", metrics.Bucket10s)
metricChainForkCount = metrics.LazyLoadCounter("chain_fork_count")
metricChainForkSize = metrics.LazyLoadGauge("chain_fork_gauge")
metricBlockProcessingLockCount = metrics.LazyLoadCounterVec("block_processing_lock_count", []string{"type"})
metricBlockProcessingLockDuration = metrics.LazyLoadHistogram("block_processing_lock_duration_ms", metrics.Bucket10s)
)
9 changes: 8 additions & 1 deletion cmd/thor/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,15 @@ func (n *Node) txStashLoop(ctx context.Context) {

// guardBlockProcessing adds lock on block processing and maintains block conflicts.
func (n *Node) guardBlockProcessing(blockNum uint32, process func(conflicts uint32) error) error {
startTime := mclock.Now()
n.processLock.Lock()
defer n.processLock.Unlock()
metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "acquired"})
defer func() {
n.processLock.Unlock()
metricBlockProcessingLockCount().AddWithLabel(1, map[string]string{"type": "released"})
timeElapsed := mclock.Now() - startTime
metricBlockProcessingLockDuration().Observe(time.Duration(timeElapsed).Milliseconds())
}()

if blockNum > n.maxBlockNum {
if blockNum > n.maxBlockNum+1 {
Expand Down

0 comments on commit 79d7c06

Please sign in to comment.