Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't export vochaininfo metrics during blocksync #1233

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions vochain/vochaininfo/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ 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()
blocksyncHeight = blocksyncMetrics.NewCounter("vochain_sync_height")
blocksyncBPM = blocksyncMetrics.NewCounter("vochain_sync_blocks_per_minute")
)
15 changes: 13 additions & 2 deletions vochain/vochaininfo/vochaininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func NewVochainInfo(node *vochain.BaseApplication) *VochainInfo {
}

func (vi *VochainInfo) updateCounters() {
if !vi.vnode.IsSynced() {
blocksyncHeight.Set(uint64(vi.vnode.Height()))
blocksyncBPM.Set(uint64(vi.BlocksLastMinute()))
return
}
height.Set(uint64(vi.vnode.Height()))

pc, err := vi.vnode.State.CountProcesses(true)
Expand Down Expand Up @@ -62,7 +67,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 Expand Up @@ -259,7 +263,11 @@ func (vi *VochainInfo) Start(sleepSecs uint64) {
panic("sleepSecs cannot be zero")
}
log.Infof("starting vochain info service every %d seconds", sleepSecs)
metrics.NewGauge("vochain_tokens_burned",

metrics.UnregisterSet(viMetrics)
metrics.RegisterSet(blocksyncMetrics)

viMetrics.NewGauge("vochain_tokens_burned",
func() float64 { return float64(vi.TokensBurned()) })

var duration time.Duration
Expand All @@ -270,6 +278,9 @@ func (vi *VochainInfo) Start(sleepSecs uint64) {
duration = time.Second * time.Duration(sleepSecs)
for {
select {
case <-vi.vnode.WaitUntilSynced():
metrics.RegisterSet(viMetrics)
metrics.UnregisterSet(blocksyncMetrics)
case <-time.After(duration):
vi.updateCounters()
currentHeight = uint64(vi.vnode.Height())
Expand Down
Loading