Skip to content

Commit

Permalink
don't export vochaininfo metrics during blocksync
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui committed Jan 8, 2024
1 parent 6eb0e36 commit 1dfe271
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
21 changes: 12 additions & 9 deletions vochain/vochaininfo/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package vochaininfo
import "github.com/VictoriaMetrics/metrics"

var (
height = metrics.NewCounter("vochain_height") // Height of the vochain (last block)
voteCount = metrics.NewCounter("vochain_vote_tree") // Total vote count
processTreeSize = metrics.NewCounter("vochain_process_tree") // Size of the process tree
accountTreeSize = metrics.NewCounter("vochain_account_tree") // Size of the account tree
sikTreeSize = metrics.NewCounter("vochain_sik_tree") // Size of the SIK tree
mempoolSize = metrics.NewCounter("vochain_mempool") // Number of Txs in the mempool
voteCacheSize = metrics.NewCounter("vochain_vote_cache") // Size of the current vote cache
blockPeriodMinute = metrics.NewCounter("vochain_block_period_minute") // Block period for the last minute
blocksSyncLastMinute = metrics.NewCounter("vochain_blocks_sync_minute") // Blocks synced the last minute
viMetrics = metrics.NewSet()
height = viMetrics.NewCounter("vochain_height") // Height of the vochain (last block)
voteCount = viMetrics.NewCounter("vochain_vote_tree") // Total vote count
processTreeSize = viMetrics.NewCounter("vochain_process_tree") // Size of the process tree
accountTreeSize = viMetrics.NewCounter("vochain_account_tree") // Size of the account tree
sikTreeSize = viMetrics.NewCounter("vochain_sik_tree") // Size of the SIK tree
mempoolSize = viMetrics.NewCounter("vochain_mempool") // Number of Txs in the mempool
voteCacheSize = viMetrics.NewCounter("vochain_vote_cache") // Size of the current vote cache
blockPeriodMinute = viMetrics.NewCounter("vochain_block_period_minute") // Block period for the last minute

blocksyncMetrics = metrics.NewSet()
blocksyncBPM = blocksyncMetrics.NewCounter("vochain_sync_blocks_per_minute")
)
11 changes: 10 additions & 1 deletion vochain/vochaininfo/vochaininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ func NewVochainInfo(node *vochain.BaseApplication) *VochainInfo {
}

func (vi *VochainInfo) updateCounters() {
if vi.vnode.IsSynchronizing() {
metrics.UnregisterSet(viMetrics)
metrics.RegisterSet(blocksyncMetrics)
blocksyncBPM.Set(uint64(vi.BlocksLastMinute()))
return
}
// TODO: do this only once when sync is finished, instead of on every updateCounters
metrics.RegisterSet(viMetrics)
metrics.UnregisterSet(blocksyncMetrics)

height.Set(uint64(vi.vnode.Height()))

pc, err := vi.vnode.State.CountProcesses(true)
Expand Down Expand Up @@ -62,7 +72,6 @@ func (vi *VochainInfo) updateCounters() {
voteCacheSize.Set(uint64(vi.vnode.State.CacheSize()))
mempoolSize.Set(uint64(vi.vnode.MempoolSize()))
blockPeriodMinute.Set(uint64(vi.BlockTimes()[0].Milliseconds()))
blocksSyncLastMinute.Set(uint64(vi.BlocksLastMinute()))
}

// Height returns the current number of blocks of the blockchain.
Expand Down

0 comments on commit 1dfe271

Please sign in to comment.