Repository navigation
feat(monitoring): map active nodes by declared region on the chain dashboard - #2056
Conversation
…shboard
Every node's CapacityBond registry already holds the whole network's
NodeId -> regionHint map, but no metric carried a region, so nothing
could be put on a map.
- New gauge decdn_staker_set_active_by_region{node_region}: active
stakers per region, recomputed at bootstrap, at the end of every clean
watcher tick and after each resync. Values pass Region::parse, so the
ISO allowlist bounds cardinality. A region with no active node loses
its series. The label is node_region because every dashboard already
filters on a scrape-side region label.
- New gauge decdn_staker_set_active_unknown_region: active stakers with
an empty or invalid regionHint.
- The registry follows RegionUpdated, so a region change reaches the
region map (and the ADR 030 latency penalty) on the next tick instead
of the 15-minute re-enumeration.
- dashboard-chain.json gains a Geomap panel (country lookup,
max by node_region), a per-region table that also lists codes the map
cannot place (user-assigned, XK, SS), and an unknown-region stat.
- appendix-observability documents both gauges and names the family as
the one exception to the zero-export rule.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
RegionUpdated currently stores raw regionHint strings without normalization, which can break downstream region equality semantics and should be normalized via Region::parse before insertion.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds chain-dashboard visibility for operator-declared regions by exporting a per-region active-staker metric from each node’s CapacityBond registry view, and visualizing it as a world map + table + “unknown region” stat on the decdn-chain Grafana dashboard.
Changes:
- Export
decdn_staker_set_active_by_region{node_region}anddecdn_staker_set_active_unknown_regionfrom the node metrics endpoint, updated on bootstrap, watcher ticks, and resync. - Track
RegionUpdatedin the CapacityBond registry projection and publish updated per-region counts on each clean tick and after resync. - Add new “Active nodes by country/region” panels to
monitoring/dashboard-chain.jsonand document the metric family + exception semantics in observability docs and the changelog.
| File | Description |
|---|---|
| monitoring/dashboard-chain.json | Adds geomap/table/stat panels driven by the new per-region active-staker gauges. |
| crates/node/src/metrics.rs | Introduces the labelled gauge family + unknown-region gauge, plus publishing/removal logic and tests. |
| crates/node/src/dht/capacity_bond_registry.rs | Subscribes to RegionUpdated and publishes per-region active-node counts at tick/resync/bootstrap. |
| CHANGELOG.md | Documents the new metrics and dashboard panels. |
| adr/appendix-observability.md | Documents the new metrics and clarifies the “no series at zero” exception for the region map family. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.97% (was 82.94%, ▲ +0.03%) — 80250/96716 lines
History
|
The contract only length-checks regionHint, and every write path into the region map (NodeRegistered, the getRegisteredNodes enumeration, and RegionUpdated) stored the raw string. The ADR 030 latency penalty compares that string against the node's own normalized identity.region, so a peer that registered " de " never matched "DE". All three paths now store the Region::parse form and treat an empty or invalid hint as absence. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

Summary
Adds a world map of active nodes to the chain dashboard (
decdn-chain). Every node's CapacityBond registry already holds the whole network'sNodeId → regionHintmap (ADR 030), so exporting it as a gauge lets a single scrape map the network.decdn_staker_set_active_by_region{node_region}:Region::parse, so the ISO allowlist bounds cardinality.decdn_staker_set_active_unknown_region: active stakers with an empty or invalidregionHint. After each tick, the two gauges together equaldecdn_staker_set_active_count.RegionUpdated. A region change now reaches the region map on the next tick instead of waiting for the 15-minute re-enumeration. This also speeds up the ADR 030 latency penalty, which reads the same map.max by (node_region));adr/appendix-observability.mdgets both registry rows, and names this family as the one exception to the zero-export rule. There is also a CHANGELOG entry under### Added.Design notes
node_region, notregion. Every dashboard selector already filters on a scrape-sideregiontarget label. Withhonor_labels: false, a clashing metric label would be renamed toexported_region.maxacross nodes, notsum. Every node reports the same network view, so summing would multiply the counts by fleet size.Familycannot list its children, soMetricstracks the published regions. It sets live children before it removes stale ones, all under one lock.Test plan
cargo nextest run -p decdn-node: 1153 passed. New tests:tick_publishes_active_nodes_by_regionregion_updated_moves_the_node_on_the_next_tickresync_republishes_the_region_splitstaker_set_active_by_region_replaces_the_previous_mapmonitoring_selectors_are_exportedgatecargo clippy --workspace --all-targets -D warnings, rustdoc-D warnings,cargo fmt, and pre-commit.g_node_04_blacklist_complianceanvil e2e test (exercisesupdateRegion): 5/5 passed.monitoring/dashboard-chain.jsoninto Grafana and check the geomap renders against nodes running this build.🤖 Generated with Claude Code