Skip to content

feat(NODE-1965): Add metrics to route provider & routing table manager#210

Merged
blind-oracle merged 6 commits into
mainfrom
igor/add-metrics
Jun 23, 2026
Merged

feat(NODE-1965): Add metrics to route provider & routing table manager#210
blind-oracle merged 6 commits into
mainfrom
igor/add-metrics

Conversation

@blind-oracle

Copy link
Copy Markdown
Collaborator

No description provided.

@blind-oracle blind-oracle requested a review from a team as a code owner June 22, 2026 13:02
@zeropath-ai

zeropath-ai Bot commented Jun 22, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to c1cbbda.

Security Overview
Detected Code Changes
Change Type Relevant files
Dependency updates ► Cargo.lock
    Update arrayvec to 0.7.7
    Update syn to 2.0.118
    Update bytes to 1.12.0
    Update getrandom to 0.4.3
    Update itertools to 0.15.0
    Update leb128 to 0.2.7
    Update log to 0.4.33
    Update mail-auth to 0.9.1
    Update mail-parser to 0.11.4
    Update quick-xml to 0.40.1
    Update quinn to 0.11.11
    Update quinn-proto to 0.11.15
    Update quote to 1.0.46
    Update rand to 0.8.5
    Update rustls to 0.23.41
    Update time to 0.3.51
    Update time-macros to 0.2.30
    Update tower-http to 0.7.0
    Update webpki-root-certs to 1.0.8
    Update webpki-roots to 1.0.8
Dependency updates ► Cargo.toml
    Update ic-custom-domains-base to 0.2.3
    Update itertools to 0.15.0
    Update tower-http to 0.7
Enhancement ► src/core.rs
    Pass registry to setup_route_provider
    Pass registry to routing_table_manager
► src/routing/ic/route_provider/fetcher.rs
    Add metrics for node fetching
► src/routing/ic/route_provider/health.rs
    Add metrics for node health checks
► src/routing/ic/route_provider/mod.rs
    Pass registry to setup_route_provider
► src/routing/ic/route_provider/provider.rs
    Add metrics for picked nodes
    Pass registry to DynamicRouteProvider
► src/routing/ic/route_provider/routes.rs
    Add metrics for active nodes
Refactor ► src/routing/ic/route_provider/mod.rs
    Add name field to Node struct

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RoutingTableManager for subnet discovery and per-subnet data fetches.
  • Add Prometheus metrics to the route provider pipeline (node fetcher, health checker, routes manager) and thread &Registry through constructors.
  • Extend Node to include a name used 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_nodes is never updated, so the gauge will keep the previous non-zero value even though routes is 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

  • success for route_provider_fetcher_count / route_provider_fetcher_duration is currently derived from res.is_ok(), which treats an empty node list as a successful fetch even though the function returns Err(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.

Comment thread src/routing/ic/routing_table_manager.rs
@blind-oracle blind-oracle enabled auto-merge June 23, 2026 12:50
@blind-oracle blind-oracle merged commit 8d54093 into main Jun 23, 2026
6 checks passed
@blind-oracle blind-oracle deleted the igor/add-metrics branch June 23, 2026 13:08
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.

3 participants