Skip to content

fix(scanner+metrics): route listener block counter through names module (closes #328)#341

Merged
obchain merged 1 commit intomainfrom
fix/328-listener-metric-name
Apr 26, 2026
Merged

fix(scanner+metrics): route listener block counter through names module (closes #328)#341
obchain merged 1 commit intomainfrom
fix/328-listener-metric-name

Conversation

@obchain
Copy link
Copy Markdown
Owner

@obchain obchain commented Apr 26, 2026

Summary

  • New names::LISTENER_BLOCKS_RECEIVED_TOTAL constant + record_block_received(chain) helper.
  • listener.rs::publish now calls the typed helper instead of a raw string literal.
  • Grafana chain template variable swapped to charon_listener_blocks_received_total so the dropdown populates the moment the WS subscription fires new_heads, not after the first pipeline tick.
  • Tighten SCANNER_BLOCKS_TOTAL description to "per pipeline tick" so the two counters cannot drift in operator mental models again.

Why

The old raw-string charon_blocks_received_total was never queried by any dashboard or alert. The dashboard's chain template var queried charon_scanner_blocks_total (bumped per pipeline tick), so fresh imports stayed on "No Data" for several minutes after cold boot until the first pipeline tick landed. Closes #328.

Test plan

  • cargo build --workspace clean
  • cargo test --workspace --lib 56/56
  • No external references to the old charon_blocks_received_total name (rg)
  • Soak test against fork — confirm the chain dropdown populates immediately on WS connect

…le (closes #328)

`crates/charon-scanner/src/listener.rs::publish` emitted the counter
via a raw `metrics::counter!("charon_blocks_received_total", ...)`
string literal, bypassing `charon_metrics::names::*`. The dashboard
and `chain` template variable both queried `charon_scanner_blocks_total`
(bumped per pipeline tick from `record_block_scanned`), so the
listener counter was a write-only metric that consumed cardinality
without ever appearing on a panel — and worse, the chain template
variable wouldn't populate until the pipeline's first tick landed,
leaving fresh dashboard imports stuck on "No Data" for several
minutes after a cold boot.

Add `names::LISTENER_BLOCKS_RECEIVED_TOTAL = "charon_listener_blocks_received_total"`
plus a typed `record_block_received(chain)` helper, route the
listener call site through it, register it in `describe_all`, and
swap the dashboard's `chain` template variable to query the listener
counter so panels populate the moment the websocket subscription
delivers `new_heads` rather than waiting for the first pipeline tick.

`describe_counter!` for `SCANNER_BLOCKS_TOTAL` updated to clarify
"per pipeline tick" so the two counters can't drift in operator
mental models again.
@obchain obchain merged commit b75a030 into main Apr 26, 2026
6 checks passed
@obchain obchain deleted the fix/328-listener-metric-name branch April 26, 2026 10:42
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.

scanner: listener.rs hardcodes charon_blocks_received_total outside the names module — dashboard uses charon_scanner_blocks_total

1 participant