sc-hop: add Prometheus metrics#12662
Open
x3c41a wants to merge 6 commits into
Open
Conversation
x3c41a
marked this pull request as ready for review
July 16, 2026 11:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
substrate_hop_pool_entries/substrate_hop_pool_bytes/substrate_hop_pool_max_bytessubstrate_hop_pool_inserts_totaloutcome(ok or HopError variant)substrate_hop_pool_inserted_bytes_totalsubstrate_hop_pool_removed_totalreasoninacked,expired_promoted,expired_unpromoted,corruptsubstrate_hop_rpc_requests_totalmethod,outcomesubstrate_hop_promotion_submissions_totaloutcomeinsubmitted,failedsubstrate_hop_promotions_confirmed_total/substrate_hop_promotions_abandoned_totalsubstrate_hop_promotion_backlog/substrate_hop_promotion_enabledsubstrate_hop_maintenance_tick_duration_secondsremoved_total{reason="expired_unpromoted"}andpromotions_abandoned_totalare the silent data-loss signals: entries that left the pool without ever landing on-chain.Notes:
HopMetricsmirrorsbitswap_metrics.rs: all recorders are no-ops without a registry. It lives inHopDataPool, shared by the RPC server and the maintenance task.Gauge<U64>wraps on underflow (prometheus 0.13fetch_sub), so delta bookkeeping would poison the gauge forever on any drift. Same pattern as the fork-aware txpool (active_viewsetc.), statement store, and the dispute-coordinator queue gauges.substrate_rpc_calls_started/finished/time{method}(withis_error) for every method includinghop_*.substrate_hop_rpc_requests_total{method,outcome}only adds the error-variant granularity (not_found,rate_limited,pool_full, ...) thatis_errorcan't show.HopParams::build_poolandHopDataPool::newgain a metrics/registry parameter; a metrics registration failure only disables metrics (txpoolMetricsLinkconvention), never pool construction. Omni-node passes its existing registry.submissions_total{submitted}only means accepted by the local tx pool; inclusion is whatconfirmed_totalcounts (viais_promoted_on_chainon the next cycle).get_promotablenow 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.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.