Skip to content

forkable: add WithFinalizedBlockNumMetric option#61

Merged
maoueh merged 1 commit into
developfrom
feature/finalized-block-num-metric
Jul 22, 2026
Merged

forkable: add WithFinalizedBlockNumMetric option#61
maoueh merged 1 commit into
developfrom
feature/finalized-block-num-metric

Conversation

@maoueh

@maoueh maoueh commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Why

Firehose apps expose head_block_number{app} but nothing telling how far behind finality that head is. firehose-core is adding a finalized_block_number{app} metric so dashboards can compute head↔finality drift in blocks.

The relayer's head metrics are set inside the forkable's live-metrics path, so the finalized number has to be set there too — computing it elsewhere (a ticker, a per-source handler) would report head and finalized from different observation points.

What

  • New forkable.WithFinalizedBlockNumMetric(m Uint64Metric) option. On the live path only, it reports blk.LibNum of the block that just became head, next to the existing head block number / time drift / relative drift metrics.
  • Uint64Metric is a minimal interface{ SetUint64(uint64) } so consumers own their metric definition and bstream does not have to depend on them.
  • Separate option rather than a change to WithMetrics, so existing callers keep compiling.

Tests

forkable/metrics_test.go covers the value being set from LibNum on the live path, and not being set when live metrics are off.

Reports the LIB number of the block that just became head, on the live
metrics path next to the existing head block number and drift metrics.
Paired with the head block number metric, it lets dashboards show how far
behind finality an app's head is.

The option takes a minimal Uint64Metric interface rather than a concrete
type, so consumers (firehose-core) can own the metric definition without
bstream depending on them. It is a separate option instead of a change to
WithMetrics so existing callers keep compiling.
@maoueh
maoueh merged commit 743b153 into develop Jul 22, 2026
3 checks passed
@maoueh
maoueh deleted the feature/finalized-block-num-metric branch July 22, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant