statesync/rpc: metrics for the statesync and the rpc SyncInfo (#6795)

This commit is contained in:
JayT106
2021-09-21 03:22:16 -04:00
committed by GitHub
parent 9dfdc62eb7
commit 84ffaaaf37
14 changed files with 500 additions and 52 deletions

View File

@@ -20,12 +20,19 @@ func TestStatus(t *testing.T) {
Call: mock.Call{
Response: &ctypes.ResultStatus{
SyncInfo: ctypes.SyncInfo{
LatestBlockHash: bytes.HexBytes("block"),
LatestAppHash: bytes.HexBytes("app"),
LatestBlockHeight: 10,
MaxPeerBlockHeight: 20,
TotalSyncedTime: time.Second,
RemainingTime: time.Minute,
LatestBlockHash: bytes.HexBytes("block"),
LatestAppHash: bytes.HexBytes("app"),
LatestBlockHeight: 10,
MaxPeerBlockHeight: 20,
TotalSyncedTime: time.Second,
RemainingTime: time.Minute,
TotalSnapshots: 10,
ChunkProcessAvgTime: time.Duration(10),
SnapshotHeight: 10,
SnapshotChunksCount: 9,
SnapshotChunksTotal: 10,
BackFilledBlocks: 9,
BackFillBlocksTotal: 10,
},
}},
}
@@ -56,4 +63,12 @@ func TestStatus(t *testing.T) {
assert.EqualValues(20, st.SyncInfo.MaxPeerBlockHeight)
assert.EqualValues(time.Second, status.SyncInfo.TotalSyncedTime)
assert.EqualValues(time.Minute, status.SyncInfo.RemainingTime)
assert.EqualValues(10, st.SyncInfo.TotalSnapshots)
assert.EqualValues(time.Duration(10), st.SyncInfo.ChunkProcessAvgTime)
assert.EqualValues(10, st.SyncInfo.SnapshotHeight)
assert.EqualValues(9, status.SyncInfo.SnapshotChunksCount)
assert.EqualValues(10, status.SyncInfo.SnapshotChunksTotal)
assert.EqualValues(9, status.SyncInfo.BackFilledBlocks)
assert.EqualValues(10, status.SyncInfo.BackFillBlocksTotal)
}

View File

@@ -11,6 +11,7 @@ import (
mempl "github.com/tendermint/tendermint/internal/mempool"
"github.com/tendermint/tendermint/internal/p2p"
"github.com/tendermint/tendermint/internal/proxy"
"github.com/tendermint/tendermint/internal/statesync"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
@@ -91,12 +92,13 @@ type Environment struct {
PeerManager peerManager
// objects
PubKey crypto.PubKey
GenDoc *types.GenesisDoc // cache the genesis structure
EventSinks []indexer.EventSink
EventBus *types.EventBus // thread safe
Mempool mempl.Mempool
BlockSyncReactor consensus.BlockSyncReactor
PubKey crypto.PubKey
GenDoc *types.GenesisDoc // cache the genesis structure
EventSinks []indexer.EventSink
EventBus *types.EventBus // thread safe
Mempool mempl.Mempool
BlockSyncReactor consensus.BlockSyncReactor
StateSyncMetricer statesync.Metricer
Logger log.Logger

View File

@@ -77,6 +77,16 @@ func (env *Environment) Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, err
ValidatorInfo: validatorInfo,
}
if env.StateSyncMetricer != nil {
result.SyncInfo.TotalSnapshots = env.StateSyncMetricer.TotalSnapshots()
result.SyncInfo.ChunkProcessAvgTime = env.StateSyncMetricer.ChunkProcessAvgTime()
result.SyncInfo.SnapshotHeight = env.StateSyncMetricer.SnapshotHeight()
result.SyncInfo.SnapshotChunksCount = env.StateSyncMetricer.SnapshotChunksCount()
result.SyncInfo.SnapshotChunksTotal = env.StateSyncMetricer.SnapshotChunksTotal()
result.SyncInfo.BackFilledBlocks = env.StateSyncMetricer.BackFilledBlocks()
result.SyncInfo.BackFillBlocksTotal = env.StateSyncMetricer.BackFillBlocksTotal()
}
return result, nil
}

View File

@@ -100,6 +100,14 @@ type SyncInfo struct {
TotalSyncedTime time.Duration `json:"total_synced_time"`
RemainingTime time.Duration `json:"remaining_time"`
TotalSnapshots int64 `json:"total_snapshots"`
ChunkProcessAvgTime time.Duration `json:"chunk_process_avg_time"`
SnapshotHeight int64 `json:"snapshot_height"`
SnapshotChunksCount int64 `json:"snapshot_chunks_count"`
SnapshotChunksTotal int64 `json:"snapshot_chunks_total"`
BackFilledBlocks int64 `json:"backfilled_blocks"`
BackFillBlocksTotal int64 `json:"backfill_blocks_total"`
}
// Info about the node's validator

View File

@@ -1396,6 +1396,27 @@ components:
remaining_time:
type: string
example: "0"
total_snapshots:
type: string
example: "10"
chunk_process_avg_time:
type: string
example: "1000000000"
snapshot_height:
type: string
example: "1262196"
snapshot_chunks_count:
type: string
example: "10"
snapshot_chunks_total:
type: string
example: "100"
backfilled_blocks:
type: string
example: "10"
backfill_blocks_total:
type: string
example: "100"
ValidatorInfo:
type: object
properties: