feat(NODE-1965): Add metrics to route provider & routing table manager#210
Merged
Conversation
|
✅ No security or compliance issues detected. Reviewed everything up to c1cbbda. Security Overview
Detected Code Changes
|
There was a problem hiding this comment.
Pull request overview
This PR introduces Prometheus instrumentation for IC routing components, wiring a shared prometheus::Registry through the route provider stack and the routing table manager so they can expose gauges/counters/histograms about node/subnet discovery and health.
Changes:
- Add Prometheus metrics (gauges/counters/histograms) to
RoutingTableManagerfor subnet discovery and per-subnet data fetches. - Add Prometheus metrics to the route provider pipeline (node fetcher, health checker, routes manager) and thread
&Registrythrough constructors. - Extend
Nodeto include anameused for metrics labeling.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/routing/ic/routing_table_manager.rs | Adds Metrics and records fetch counts/durations and subnet/range gauges; updates constructor to accept &Registry. |
| src/routing/ic/route_provider/routes.rs | Adds routes-manager gauge metric and updates constructor to accept &Registry. |
| src/routing/ic/route_provider/provider.rs | Threads &Registry through DynamicRouteProvider::new to downstream managers. |
| src/routing/ic/route_provider/mod.rs | Adds Registry parameter to setup_route_provider and adds name field to Node. |
| src/routing/ic/route_provider/health.rs | Adds metrics for node health checks (counts/durations, node/healthy gauges) and passes metrics into actors. |
| src/routing/ic/route_provider/fetcher.rs | Adds metrics for node fetching (counts/durations, nodes gauge) and updates FetcherManager::new signature. |
| src/core.rs | Passes the main Prometheus registry into route provider setup and routing table manager construction. |
Comments suppressed due to low confidence (2)
src/routing/ic/route_provider/routes.rs:135
- When the healthy node list becomes empty,
active_nodesis never updated, so the gauge will keep the previous non-zero value even thoughroutesis cleared. This makes the new metric incorrect (stale).
if list.is_empty() {
self.routes.store(None);
return;
}
src/routing/ic/route_provider/fetcher.rs:163
successforroute_provider_fetcher_count/route_provider_fetcher_durationis currently derived fromres.is_ok(), which treats an empty node list as a successful fetch even though the function returnsErr(RouteError::EmptyNodeList). This will mislabel failures as successes in the new metrics.
let start = Instant::now();
let res = self.fetcher.fetch_nodes().await;
let success = res.is_ok().yesno();
self.metrics
.duration
.with_label_values(&[success])
.observe(start.elapsed().as_secs_f64());
self.metrics.fetches.with_label_values(&[success]).inc();
let nodes = res?;
self.metrics.nodes.set(nodes.len() as i64);
// Safeguard against a case when (for whatever reason) an empty node list is fetched.
// If we remove all nodes, then we'll end up in a deadlock situation: we can't fetch a new (correct)
// list because there are no nodes anymore to handle the next fetch request.
if nodes.is_empty() {
return Err(RouteError::EmptyNodeList);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frankdavid
approved these changes
Jun 23, 2026
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.
No description provided.