You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(node): generate the ~125 one-liner metric recorders with a macro #1247
crates/node/src/metrics.rs (3,616 lines) is structurally sound — registration is already macro-generated via #[derive(MetricsGroup)] (metrics.rs:34-36) — but the Metrics wrapper (metrics.rs:1207-2356) hand-writes ~152 recorder methods, of which ~125 are trivial one-liners (self.decdn.<field>.inc() / .set()), each carrying its own doc comment (e.g. metrics.rs:1256-1300). That's ~350-400 mechanical lines whose only content is field-name repetition.
All 149 metric fields were verified live (no dead recorders — the indirect ones route via connection_guard() at metrics.rs:2672/2679 and the SettleParty dispatch enum at metrics.rs:2438-2510), so this is pure mechanical collapse, not surface reduction.
Proposed fix
A declarative macro (e.g. metric!(field, Counter, "doc") or a small macro_rules! block over the field list) that generates the struct field and its trivial recorder together. Doc comments stay attached; non-trivial recorders (the ones taking args, doing role dispatch, or setting gauges from computed values) stay hand-written.
Compiler-checked, zero behavior change; the /metrics encode path and SettleParty are untouched.
Acceptance
No hand-written recorder whose body is a single bare .inc()/.set() on a same-named field.
cargo doc output for the recorder surface unchanged (docs preserved through the macro).
Metrics endpoint output byte-identical for the same event sequence.
Activity
docs(node): correct three inaccurate claims in the recorders! macro d…