Repository navigation
Description
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
- 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.
- Drop the parameter from the three methods. Cleanest signature, but forecloses per-topic counters and churns the trait +
NoopMetrics+ call sites. - 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
altanoruc commentedon Jul 17, 2026
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.
refactor(node): generate the trivial metric recorders with a macro (#…
docs(gossip): stop promising a topic label the metrics cannot export (#…
docs(metrics): correct "iroh_metrics has no label support" claim (#1265)