diff --git a/packages/lodestar/src/metrics/metrics/lodestar.ts b/packages/lodestar/src/metrics/metrics/lodestar.ts index f729cdf42b0..fd981d7dd8b 100644 --- a/packages/lodestar/src/metrics/metrics/lodestar.ts +++ b/packages/lodestar/src/metrics/metrics/lodestar.ts @@ -256,6 +256,10 @@ export function createLodestarMetrics( name: "lodestar_sync_status", help: "Range sync status: [Stalled, SyncingFinalized, SyncingHead, Synced]", }), + syncUnknownParentSyncs: register.gauge({ + name: "lodestar_sync_unknown_parent_syncs_total", + help: "Total number of unknown parent syncs", + }), // Validator monitoring diff --git a/packages/lodestar/src/sync/sync.ts b/packages/lodestar/src/sync/sync.ts index 6a0ddf426c2..f208e15845c 100644 --- a/packages/lodestar/src/sync/sync.ts +++ b/packages/lodestar/src/sync/sync.ts @@ -13,12 +13,14 @@ import {fetchUnknownBlockRoot, getPeerSyncType, PeerSyncType} from "./utils"; import {MIN_EPOCH_TO_START_GOSSIP} from "./constants"; import {SyncState, SyncChainDebugState, syncStateMetric} from "./interface"; import {ISyncOptions} from "./options"; +import {IMetrics} from "../metrics"; export class BeaconSync implements IBeaconSync { private readonly config: IBeaconConfig; private readonly logger: ILogger; private readonly network: INetwork; private readonly chain: IBeaconChain; + private readonly metrics: IMetrics | null; private readonly opts: ISyncOptions; private readonly rangeSync: RangeSync; @@ -42,6 +44,7 @@ export class BeaconSync implements IBeaconSync { this.config = config; this.network = network; this.chain = chain; + this.metrics = metrics; this.logger = logger; this.rangeSync = new RangeSync(modules, this.opts); this.slotImportTolerance = SLOTS_PER_EPOCH; @@ -207,6 +210,7 @@ export class BeaconSync implements IBeaconSync { return; } + this.metrics?.syncUnknownParentSyncs.inc(1); this.processingRoots.add(parentRootHex); this.logger.verbose("Finding block for unknown ancestor root", {parentRootHex});