Repository navigation
refactor(node): remove the no-op Metrics::started() recorder (#1264) - #1324
Conversation
`Metrics::started()` was a macro-generated recorder that wrote `node_uptime_seconds.set(0)`, but `Metrics::encode()` recomputes that gauge from `started_at` on every scrape, before the registry renders — so the write was never observable. Its single call site sat on the line immediately after `Metrics::new()`, so removing it changes nothing about when uptime counts from: `new()` already stamps `started_at`. The exported `decdn_node_uptime_seconds` series is unchanged. - Drop the `started => node_uptime_seconds.set(0);` row from the `recorders!` table and its one call site in `build_infra`. - Reword the `recorders!` doc that used `started` as its example and replace the brittle hand-maintained "45 of them" count with a non-brittle qualifier. - Add a regression test pinning that uptime derives from construction (`started_at`) with no bring-up hook. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 17 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Code Review
This pull request removes the redundant started metric recorder and its corresponding initialization call, relying instead on started_at set during construction to compute node uptime. A regression test was added to verify this behavior. The review feedback suggests reducing the backdated duration in the test from 2 hours to 10 seconds to avoid potential test failures on environments with low system uptime.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR removes a misleading, effectively unobservable metrics recorder (Metrics::started()) and its lone call site, relying instead on the already-authoritative started_at timestamp that Metrics::encode() uses to compute decdn_node_uptime_seconds on every scrape. It also adds a regression test to pin that uptime counts from construction and to prevent reintroducing pre-scrape writes that can’t be observed.
Changes:
- Delete the macro-generated
Metrics::started()recorder and remove its only call site during node bring-up. - Update
recorders!macro documentation to remove the obsoletestartedexample and avoid brittle divergence-count claims. - Add a regression test asserting uptime derives from
started_atwithout any bring-up hook.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/node/src/runtime/mod.rs | Removes the now-nonexistent node_metrics.started() call from bring-up. |
| crates/node/src/metrics.rs | Drops the started recorder entry, updates recorder docs, and adds an uptime regression test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 81.50% (was 81.50%, ▲ +0.01%) — 49932/61265 lines
History
|
Address PR review: the test backdated started_at by 2h and asserted an exact 7200s. `Instant` is monotonic (boot-relative), so checked_sub(2h) underflows to None on a host with <2h uptime (ephemeral CI), and an exact as_secs() assertion races scrape-time truncation. Use a small 60s backdate and a range assertion, via a new metric_value() helper (whole-line discipline mirroring has_metric_line). Still fails hard if uptime resets to 0 — the actual regression. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Closes #1264.
Metrics::started()was a macro-generated recorder that wrotenode_uptime_seconds.set(0), butMetrics::encode()unconditionally recomputes that same gauge fromstarted_aton every scrape, before the registry renders — so theset(0)could never be observed. The method also misled: it read as if it marked the start instant, butMetrics::new()already stampsstarted_at. Its single call site (build_infra) sat on the line immediately afterMetrics::new(), so there was no meaningful gap — "count from bring-up" and "count from construction" were identical, and option 2 from the issue (re-stamp) had nothing to re-stamp. Deletion is the correct resolution; the exporteddecdn_node_uptime_secondsseries is unchanged.Changes
started => node_uptime_seconds.set(0);row from therecorders!macro table (crates/node/src/metrics.rs) — this was the entire definition of the generated method.node_metrics.started();inbuild_infra(crates/node/src/runtime/mod.rs). The removal is enforced by a compile guarantee — the method no longer exists.recorders!doc that citedstartedas its semantic-rename example (keeping the still-validconnection_opened → active_connectionsexample), and replace the brittle hand-maintained "45 of them" divergence count with a non-brittle qualifier.uptime_counts_from_construction_without_any_bring_up_hookthat backdatesstarted_atand scrapes without any hook, pinning that uptime counts from construction and guarding against a re-introduced pre-scrape write. The pre-existingkey_rotation_metrics_export_canonical_names_at_zero(uptime at 0 on fresh construction) is the complementary guard.Verification
cargo build -p decdn-node— cleancargo clippy -p decdn-node --all-targets— cleancargo fmt -- --check— cleancargo nextest run -p decdn-node— 866 passed, 0 failed (incl. the new test)grep -rn '\.started()' crates/node/src— no stray callsReview
Reviewed by the pr-review-toolkit agents (code-reviewer, comment-analyzer, pr-test-analyzer). One doc-accuracy finding (an incorrect "most entries" qualifier) was caught and fixed before this PR; all other checks came back clean.
🤖 Generated with Claude Code