Skip to content

fix(gossip,node): GossipMetrics docs promise topic labels that are silently dropped #1265

Closed

Description

@thiras

Spotted while working #1247 (PR #1263).

Problem

crates/gossip/src/metrics.rs documents three trait methods as carrying a topic label:

/// Called once per successful publish, labelled by topic.
fn inc_published(&self, topic: &str);
/// Called once per inbound envelope that passes framing, labelled by topic.
fn inc_received(&self, topic: &str);
/// Called each time a subscriber successfully reconnects after a stream drop.
fn inc_reconnected(&self, topic: &str);

The node's implementation (crates/node/src/runtime/mod.rs:2638-2650) forwards them to recorders that discard the argument:

gossip_published(_topic: &str)   => gossip_announces_published_total.inc();
gossip_received(_topic: &str)    => gossip_announces_received_total.inc();
gossip_reconnected(_topic: &str) => gossip_subscriber_reconnections_total.inc();

The topic is threaded through a public trait, across a crate boundary, and dropped. iroh-metrics 1.x has no label dimension — that is why the file elsewhere realizes would-be labels as sibling counters instead (dispatch_rejected_{global,per_source}, gossip_messages_rejected_clock_skew), a pattern its own field docs explain.

So the exported series are correct; the docs are wrong. "labelled by topic" describes an OpenMetrics label that does not and cannot exist here, which will mislead the next person wiring a dashboard or extending the trait.

Note inc_rejected(reason: &'static str) is not affected — the node genuinely branches on reason to pick a sibling counter.

Options

  1. Fix the docs — say the topic is accepted for call-site clarity and future use but is not exported as a label, and why (no label dimension in iroh-metrics 1.x). Cheapest, honest.
  2. Drop the parameter from the three methods. Cleanest signature, but forecloses per-topic counters and churns the trait + NoopMetrics + call sites.
  3. Realize the label as sibling counters per topic, matching the established pattern — only worth it if per-topic breakdown is actually wanted. Topic count is small and static.

(1) unless per-topic breakdown is on someone's roadmap, in which case (3).

Acceptance

  • No doc comment claiming a label that is not exported.
  • If the parameter stays, its doc says why it is accepted and discarded.

Activity

  1. added
    rust
    prio:low
    on Jul 17, 2026
  2. altanoruc commented on Jul 17, 2026

    @altanoruc
    Contributor

    Triage note for a later run: automated dispatch skipped this because the issue still offers three materially different outcomes (documentation-only, removing the topic parameter, or exporting per-topic sibling counters). Please select the intended outcome explicitly.

  3. self-assigned this
    on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

prio:lowrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions