Skip to content

Commit

Permalink
Update metrics counters
Browse files Browse the repository at this point in the history
  • Loading branch information
mjfh committed Sep 26, 2024
1 parent 12e0f59 commit cb51afc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
5 changes: 4 additions & 1 deletion nimbus/sync/flare/worker/update.nim
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ proc updateBlockRequests*(ctx: FlareCtxRef): bool =


proc updateMetrics*(ctx: FlareCtxRef) =
ctx.updateMetricsImpl()
let now = Moment.now()
if ctx.pool.nextUpdate < now:
ctx.updateMetricsImpl()
ctx.pool.nextUpdate = now + metricsUpdateInterval

# ------------------------------------------------------------------------------
# End
Expand Down
62 changes: 39 additions & 23 deletions nimbus/sync/flare/worker/update/metrics.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,55 @@
import
pkg/metrics,
../../worker_desc,
../headers_staged
".."/[db, blocks_staged, headers_staged]

declareGauge flare_beacon_block_number, "" &
"Block number for latest finalised header"
"Block number of latest known finalised header"

declareGauge flare_max_trusted_block_number, "" &
"Max block number for trusted headers chain starting at genesis"
declareGauge flare_state_block_number, "" &
"Max block number of imported/executed blocks"

declareGauge flare_base_block_number, "" &
"Max block number inital header chain starting at genesis"

declareGauge flare_least_verified_block_number, "" &
"Starting block number for verified higher up headers chain"
declareGauge flare_least_block_number, "" &
"Starting/min block number for higher up headers chain"

declareGauge flare_top_verified_block_number, "" &
"Top block number for verified higher up headers chain"
declareGauge flare_final_block_number, "" &
"Ending/max block number of higher up headers chain"

declareGauge flare_staged_headers_queue_size, "" &
"Number of isolated verified header chains, gaps to be filled"
declareGauge flare_headers_staged_queue_len, "" &
"Number of header list records staged for serialised processing"

declareGauge flare_headers_unprocessed, "" &
"Number of block numbers ready to fetch and stage headers"

declareGauge flare_blocks_staged_queue_len, "" &
"Number of block list records staged for importing"

declareGauge flare_blocks_unprocessed, "" &
"Number of block numbers ready to fetch and stage block data"

declareGauge flare_number_of_buddies, "" &
"Number of current worker instances"
"Number of currently active worker instances"

declareCounter flare_serial, "" &
"Serial counter for debugging"

template updateMetricsImpl*(ctx: FlareCtxRef) =
let now = Moment.now()
if ctx.pool.nextUpdate < now:
metrics.set(flare_max_trusted_block_number, ctx.layout.base.int64)
metrics.set(flare_least_verified_block_number, ctx.layout.least.int64)
metrics.set(flare_top_verified_block_number, ctx.layout.final.int64)
metrics.set(flare_beacon_block_number, ctx.lhc.beacon.header.number.int64)
metrics.set(flare_staged_headers_queue_size, ctx.headersStagedQueueLen())
metrics.set(flare_number_of_buddies, ctx.pool.nBuddies)
flare_serial.inc(1)
ctx.pool.nextUpdate += metricsUpdateInterval
metrics.set(flare_beacon_block_number, ctx.lhc.beacon.header.number.int64)

metrics.set(flare_state_block_number, ctx.dbStateBlockNumber().int64)
metrics.set(flare_base_block_number, ctx.layout.base.int64)
metrics.set(flare_least_block_number, ctx.layout.least.int64)
metrics.set(flare_final_block_number, ctx.layout.final.int64)

metrics.set(flare_headers_staged_queue_len, ctx.headersStagedQueueLen())
metrics.set(flare_headers_unprocessed,
(ctx.headersUnprocTotal() + ctx.headersUnprocBorrowed()).int64)

metrics.set(flare_blocks_staged_queue_len, ctx.blocksStagedQueueLen())
metrics.set(flare_blocks_unprocessed,
(ctx.blocksUnprocTotal() + ctx.blocksUnprocBorrowed()).int64)

metrics.set(flare_number_of_buddies, ctx.pool.nBuddies)

# End

0 comments on commit cb51afc

Please sign in to comment.