Skip to content

sc-hop: add Prometheus metrics#12662

Open
x3c41a wants to merge 6 commits into
masterfrom
ndk/hop-metrics
Open

sc-hop: add Prometheus metrics#12662
x3c41a wants to merge 6 commits into
masterfrom
ndk/hop-metrics

Conversation

@x3c41a

@x3c41a x3c41a commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Closes paritytech/polkadot-bulletin-chain#609. Same approach as #12232 (bitswap metrics).

Adds Prometheus metrics to sc-hop covering the pool, the RPC surface, and the promotion task:

Metric Type Labels
substrate_hop_pool_entries / substrate_hop_pool_bytes / substrate_hop_pool_max_bytes gauge
substrate_hop_pool_inserts_total counter outcome (ok or HopError variant)
substrate_hop_pool_inserted_bytes_total counter
substrate_hop_pool_removed_total counter reason in acked, expired_promoted, expired_unpromoted, corrupt
substrate_hop_rpc_requests_total counter method, outcome
substrate_hop_promotion_submissions_total counter outcome in submitted, failed
substrate_hop_promotions_confirmed_total / substrate_hop_promotions_abandoned_total counter
substrate_hop_promotion_backlog / substrate_hop_promotion_enabled gauge
substrate_hop_maintenance_tick_duration_seconds histogram

removed_total{reason="expired_unpromoted"} and promotions_abandoned_total are the silent data-loss signals: entries that left the pool without ever landing on-chain.

Notes:

  • HopMetrics mirrors bitswap_metrics.rs: all recorders are no-ops without a registry. It lives in HopDataPool, shared by the RPC server and the maintenance task.
  • Pool size gauges are snapshot from the authoritative counters on every mutation, never inc/dec'd: Gauge<U64> wraps on underflow (prometheus 0.13 fetch_sub), so delta bookkeeping would poison the gauge forever on any drift. Same pattern as the fork-aware txpool (active_views etc.), statement store, and the dispute-coordinator queue gauges.
  • No per-method duration histogram: the RPC middleware already records substrate_rpc_calls_started/finished/time{method} (with is_error) for every method including hop_*. substrate_hop_rpc_requests_total{method,outcome} only adds the error-variant granularity (not_found, rate_limited, pool_full, ...) that is_error can't show.
  • HopParams::build_pool and HopDataPool::new gain a metrics/registry parameter; a metrics registration failure only disables metrics (txpool MetricsLink convention), never pool construction. Omni-node passes its existing registry.
  • submissions_total{submitted} only means accepted by the local tx pool; inclusion is what confirmed_total counts (via is_promoted_on_chain on the next cycle).
  • get_promotable now counts the full in-window backlog (including entries backing off) for the gauge, refreshed each maintenance tick like other queue-depth gauges; the returned batch is unchanged.
  • Rate-limit rejections surface as inserts_total{outcome="rate_limited"} without a per-bucket reason; splitting requests/bandwidth/global can follow once Fix two DoS vectors in sc-hop rate limiter #11988 settles the limiter shape.

@x3c41a x3c41a added the T0-node This PR/Issue is related to the topic “node”. label Jul 16, 2026
@x3c41a
x3c41a marked this pull request as ready for review July 16, 2026 11:15
@x3c41a
x3c41a requested a review from karolk91 July 17, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T0-node This PR/Issue is related to the topic “node”.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HOP] Add some basic metrics

1 participant