Skip to content

Commit

Permalink
Limit how old blocks are tracked in elapsedTimeTillBecomeHead
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed May 9, 2022
1 parent 25c2191 commit 2f4cc3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 9 additions & 2 deletions packages/lodestar/src/chain/eventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,15 @@ export function onForkChoiceHead(this: BeaconChain, head: IProtoBlock): void {
});
this.syncContributionAndProofPool.prune(head.slot);
this.seenContributionAndProof.prune(head.slot);
this.metrics?.headSlot.set(head.slot);
this.metrics?.gossipBlock.elapsedTimeTillBecomeHead.observe(delaySec);

if (this.metrics) {
this.metrics.headSlot.set(head.slot);
// Only track "recent" blocks. Otherwise sync can distort this metrics heavily.
// We want to track recent blocks coming from gossip, unknown block sync, and API.
if (delaySec < 64 * this.config.SECONDS_PER_SLOT) {
this.metrics.elapsedTimeTillBecomeHead.observe(delaySec);
}
}
}

export function onForkChoiceReorg(this: BeaconChain, head: IProtoBlock, oldHead: IProtoBlock, depth: number): void {
Expand Down
10 changes: 5 additions & 5 deletions packages/lodestar/src/metrics/metrics/lodestar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,6 @@ export function createLodestarMetrics(

// Gossip block
gossipBlock: {
elapsedTimeTillBecomeHead: register.histogram({
name: "lodestar_gossip_block_elapsed_time_till_become_head",
help: "Time elappsed between block slot time and the time block becomes head",
buckets: [0.5, 1, 2, 4, 6, 12],
}),
elapsedTimeTillReceived: register.histogram({
name: "lodestar_gossip_block_elappsed_time_till_received",
help: "Time elappsed between block slot time and the time block received via gossip",
Expand All @@ -530,6 +525,11 @@ export function createLodestarMetrics(
buckets: [0.5, 1, 2, 4, 6, 12],
}),
},
elapsedTimeTillBecomeHead: register.histogram({
name: "lodestar_gossip_block_elapsed_time_till_become_head",
help: "Time elappsed between block slot time and the time block becomes head",
buckets: [0.5, 1, 2, 4, 6, 12],
}),

backfillSync: {
backfilledTillSlot: register.gauge({
Expand Down

0 comments on commit 2f4cc3f

Please sign in to comment.