Skip to content

metrics: decide whether the remaining reason-splits follow probe-hold onto {reason} labels #1475

Closed

Description

@thiras

Follow-up from #1474 (which closed #1443), filed rather than widening that PR.

What #1474 changed

The three probe-hold refusal counters collapsed onto decdn_probe_hold_unavailable_total{reason=…}.

Why this issue exists

#1443's stated motivation was that the codebase "already uses reason= labels for exactly this shape." It did not. Every other reason-style split in decdn-node fans out to sibling unlabeled counters:

Enum Location Emits to
RejectReason crates/node/src/dispatch.rs:76 dispatch_rejected_global / dispatch_rejected_per_source
RejectLayer crates/node/src/rate_limit.rs:169 probe_rate_limit_rejected_{per_peer,per_ip,global}
ChannelOpenFailureReason dispatched at crates/node/src/metrics.rs channel_open_failure_by_reason channel_open_failures_{insufficient_deposit,contract_revert,rpc_error}
AnnounceReject crates/gossip/src/validation.rs:95 gossip_announces_rejected_total + gossip_messages_rejected_clock_skew

The convention is stated deliberately in crates/node/src/metrics.rs at :214, :253 and :1086 ("One Counter per reason — like the dispatch_rejected_* convention"), and crates/gossip/src/metrics.rs:10-33 records it as a choice, not a backend limitation.

So after #1474 the crate has one labeled counter and four sibling-counter splits. The docs assert a convention that is now only half true. That is the actual inconsistency, and it should be resolved deliberately in one direction.

The decision

  1. Unify onto labels. Convert the four splits above to Family<L, Counter>. Ends the fork. Cost: renames ~8 operator-facing metrics (several Mandatory in the canonical registry), touching adr/appendix-observability.md, monitoring/prometheus-alerts.yml, monitoring/grafana-dashboard.json and docs/runbook.md, plus a CHANGELOG migration entry per family. Note appendix-observability.md already blesses the labeled form — its Canonical Metric Name Cross-Reference maps gossip_messages_rejected_clock_skew → decdn_gossip_messages_rejected_total{reason="clock_skew"}, which the code implements as a sibling counter. That row is already aspirational.
  2. Keep sibling counters as the convention and treat probe_hold_unavailable as the documented exception (its three values genuinely share one alert and one remedy axis, which is the argument Collapse the three probe-hold counters into one {reason} label (observability) #1443 rested on). Cheapest; requires only that the :214/:253/:1086 comments name the exception so the next reader doesn't have to rediscover it.

If option 1 is chosen

The mechanics are settled by #1474 and can be copied: label enum with EncodeLabelValue (the derive snake_cases variant names), a private EncodeLabelSet struct, children pre-materialized in Metrics::new() so every series still exports at zero (a Family creates children lazily — without this a dashboard shows a gap where a counter previously showed a zero), and a hand-written recorder that matches on the enum, since recorders! only reaches self.decdn.$field.

Non-negotiable either way: no metric may silently stop exporting at zero, and any alert whose remedy applies to only one reason must gain the corresponding label filter — that is what the #739/#757 split bought and what #1474 preserved via reason="exhausted".

Metadata

Metadata

Assignees

Labels

rust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions