metrics: add expected height metric
This commit is contained in:
parent
c573310c77
commit
f7b52d16f5
@ -125,6 +125,8 @@ type Syncer struct {
|
|||||||
verifier ffiwrapper.Verifier
|
verifier ffiwrapper.Verifier
|
||||||
|
|
||||||
windowSize int
|
windowSize int
|
||||||
|
|
||||||
|
tickerCtxCancel context.CancelFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSyncer creates a new Syncer object.
|
// NewSyncer creates a new Syncer object.
|
||||||
@ -166,11 +168,35 @@ func NewSyncer(sm *stmgr.StateManager, bsync *blocksync.BlockSync, connmgr connm
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (syncer *Syncer) Start() {
|
func (syncer *Syncer) Start() {
|
||||||
|
tickerCtx, tickerCtxCancel := context.WithCancel(context.Background())
|
||||||
syncer.syncmgr.Start()
|
syncer.syncmgr.Start()
|
||||||
|
|
||||||
|
syncer.tickerCtxCancel = tickerCtxCancel
|
||||||
|
|
||||||
|
go syncer.runMetricsTricker(tickerCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (syncer *Syncer) runMetricsTricker(tickerCtx context.Context) {
|
||||||
|
genesisTime := time.Unix(int64(syncer.Genesis.MinTimestamp()), 0)
|
||||||
|
ticker := build.Clock.Ticker(time.Duration(build.BlockDelaySecs) * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ticker.C:
|
||||||
|
sinceGenesis := build.Clock.Now().Sub(genesisTime)
|
||||||
|
expectedHeight := int64(sinceGenesis.Seconds()) / int64(build.BlockDelaySecs)
|
||||||
|
|
||||||
|
stats.Record(tickerCtx, metrics.ChainNodeHeightExpected.M(int64(expectedHeight)))
|
||||||
|
case <-tickerCtx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (syncer *Syncer) Stop() {
|
func (syncer *Syncer) Stop() {
|
||||||
syncer.syncmgr.Stop()
|
syncer.syncmgr.Stop()
|
||||||
|
syncer.tickerCtxCancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// InformNewHead informs the syncer about a new potential tipset
|
// InformNewHead informs the syncer about a new potential tipset
|
||||||
|
@ -30,6 +30,7 @@ var (
|
|||||||
var (
|
var (
|
||||||
LotusInfo = stats.Int64("info", "Arbitrary counter to tag lotus info to", stats.UnitDimensionless)
|
LotusInfo = stats.Int64("info", "Arbitrary counter to tag lotus info to", stats.UnitDimensionless)
|
||||||
ChainNodeHeight = stats.Int64("chain/node_height", "Current Height of the node", stats.UnitDimensionless)
|
ChainNodeHeight = stats.Int64("chain/node_height", "Current Height of the node", stats.UnitDimensionless)
|
||||||
|
ChainNodeHeightExpected = stats.Int64("chain/node_height_expected", "Expected Height of the node", stats.UnitDimensionless)
|
||||||
ChainNodeWorkerHeight = stats.Int64("chain/node_worker_height", "Current Height of workers on the node", stats.UnitDimensionless)
|
ChainNodeWorkerHeight = stats.Int64("chain/node_worker_height", "Current Height of workers on the node", stats.UnitDimensionless)
|
||||||
MessagePublished = stats.Int64("message/published", "Counter for total locally published messages", stats.UnitDimensionless)
|
MessagePublished = stats.Int64("message/published", "Counter for total locally published messages", stats.UnitDimensionless)
|
||||||
MessageReceived = stats.Int64("message/received", "Counter for total received messages", stats.UnitDimensionless)
|
MessageReceived = stats.Int64("message/received", "Counter for total received messages", stats.UnitDimensionless)
|
||||||
@ -62,6 +63,10 @@ var (
|
|||||||
Measure: ChainNodeHeight,
|
Measure: ChainNodeHeight,
|
||||||
Aggregation: view.LastValue(),
|
Aggregation: view.LastValue(),
|
||||||
}
|
}
|
||||||
|
ChainNodeHeightExpectedView = &view.View{
|
||||||
|
Measure: ChainNodeHeightExpected,
|
||||||
|
Aggregation: view.LastValue(),
|
||||||
|
}
|
||||||
ChainNodeWorkerHeightView = &view.View{
|
ChainNodeWorkerHeightView = &view.View{
|
||||||
Measure: ChainNodeWorkerHeight,
|
Measure: ChainNodeWorkerHeight,
|
||||||
Aggregation: view.LastValue(),
|
Aggregation: view.LastValue(),
|
||||||
@ -138,6 +143,7 @@ var (
|
|||||||
var DefaultViews = append([]*view.View{
|
var DefaultViews = append([]*view.View{
|
||||||
InfoView,
|
InfoView,
|
||||||
ChainNodeHeightView,
|
ChainNodeHeightView,
|
||||||
|
ChainNodeHeightExpectedView,
|
||||||
ChainNodeWorkerHeightView,
|
ChainNodeWorkerHeightView,
|
||||||
BlockReceivedView,
|
BlockReceivedView,
|
||||||
BlockValidationFailureView,
|
BlockValidationFailureView,
|
||||||
|
Loading…
Reference in New Issue
Block a user