mukan-consensus/blocksync/metrics.go
Mukan Erkin Törük c6a41110d1
Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:20 +03:00

35 lines
958 B
Go

package blocksync
import (
"git.cw.tr/mukan-network/mukan-consensus/types"
"github.com/go-kit/kit/metrics"
)
const (
// MetricsSubsystem is a subsystem shared by all metrics exposed by this
// package.
MetricsSubsystem = "blocksync"
)
//go:generate go run ../scripts/metricsgen -struct=Metrics
// Metrics contains metrics exposed by this package.
type Metrics struct {
// Whether or not a node is block syncing. 1 if yes, 0 if no.
Syncing metrics.Gauge
// Number of transactions in the latest block.
NumTxs metrics.Gauge
// Total number of transactions.
TotalTxs metrics.Gauge
// Size of the latest block.
BlockSizeBytes metrics.Gauge
// The height of the latest block.
LatestBlockHeight metrics.Gauge
}
func (m *Metrics) recordBlockMetrics(block *types.Block) {
m.NumTxs.Set(float64(len(block.Txs)))
m.TotalTxs.Add(float64(len(block.Txs)))
m.BlockSizeBytes.Set(float64(block.Size()))
m.LatestBlockHeight.Set(float64(block.Height))
}