Repository navigation
feat(metrics,monitoring): meter the serve-path cache hit rate; surface the failure residual - #2071
Merged
Merged
Conversation
…e the failure residual
The paid serve path streams through `export_bao_range_stream` and never calls
`CacheEngine::get`, so `decdn_cache_{hits,misses,bytes_returned}_total` sit at a
permanent zero on a node serving paying clients however full its store is. The
fleet dashboard inherited that: its hit-ratio panel read 0% against 71 GB of
cached content, and its headline throughput panel plotted `bytes_returned` as
"served" while the real egress counter showed 170 GB a day.
Add `decdn_serve_cache_{hit,partial_hit,miss}_total`, bumped at the
blob-availability gate ahead of the load-shed admission so the ratio stays a
property of the store rather than of current pressure. The partial hit is a
sibling rather than a fold-in: it is the payoff of partial-holder
advertisement, and folding it into the plain hit would hide whether that
mechanism carries traffic. Correct the registry rows and the cache crate's
operator ratios to say which counter answers which question.
On the dashboards: the overview throughput panel reads `decdn_bytes_served_total`,
both hit-ratio panels read the new family, and two panels land that make
standing failures legible — a residual of seller-leg failures no reason counter
claims (live fleet: ~297/day), and node-to-node pull success rate, which reads
as a ratio pinned at zero rather than as low traffic. `bad_binding` and
`pool_open_failures` join the breakdowns they were missing from, and eleven
further exported-but-unplotted series land on their existing panels.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Sep 20, 2026
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Residual dashboards mix unrelated counters and omit pool-exhaustion failures.
Review effort: Lite
Findings: None
What changed in this PR
Adds serve-path cache hit metrics and expands Grafana monitoring for delivery, pull success, and failure residuals.
Changes:
- Adds complete, partial-hit, and miss counters with tests.
- Updates throughput and hit-ratio dashboards.
- Adds coverage for previously unplotted metrics.
| File | Summary |
|---|---|
monitoring/grafana-dashboard.json |
Updates overview panels and residual queries. |
monitoring/dashboard-node.json |
Adds node transport, probe, and rate-limit metrics. |
monitoring/dashboard-delivery.json |
Adds delivery metrics, hit ratios, and residual queries. |
monitoring/dashboard-chain.json |
Adds watcher and redemption metrics. |
crates/node/tests/client_loopback.rs |
Verifies serve-cache metrics. |
crates/node/src/metrics.rs |
Defines and tests serve-cache metrics. |
crates/node/src/handlers/client/dispatch.rs |
Records serve-path classifications. |
crates/cache/src/metrics.rs |
Clarifies cache metric scope. |
CHANGELOG.md |
Documents observability changes. |
adr/appendix-observability.md |
Updates the metric registry. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 83.16% (was 83.16%, ● 0.00%) — 81725/98274 lines
History
|
…partial and miss branches Review of the previous commit found the metering placement sound but several of its written claims wrong. The claims are the part operators act on, so they get the same standard as the code. `decdn_cache_misses_total` is not `get`-scoped. It is also bumped by `populate`/`populate_local` and `pull_through_range`, which the serve-path fill tiers do call. Only `hits` and `bytes_returned` are `get`-exclusive, so the pair reads as a populated permanent 0% on a serving node, not as an empty series — a sharper statement of the bug than the one it replaces, and the cache module doc had begun contradicting its own field doc. `decdn_serve_cache_miss_total` does not imply a fill tier ran. The bump precedes the shed gate, the floor reservation and the `pull_authorized` check every tier is gated on, so a shed refusal, a floor refusal and an unbound request all count with no origin and no peer asked. It also absorbs a store fault during the partial-coverage lookup, which `.ok()?` renders as absence. "Exactly one of the three per request" omitted two carve-outs, not one: a withdrawn hash and a `serve_audit` store fault both reach the gate and are refused without an availability classification. The partial-hit row cited ADR 038 § Serve side, which covers bao proof sources. The mechanism the counter measures the payoff of is ADR 022 § Range-keyed partial-holder discovery. Origin-egress amplification does not reach exactly 1.0 on a pure pass-through: `bytes_served` is the bao wire form over chunk-group-aligned ranges and includes downstream-node egress, while `pull_through_bytes` is raw origin content. Stated as a trend with the gap named, rather than as a calibration point operators would anchor on. Tests now cover the two branches that had none. The partial branch is pinned in `partial_serve.rs` where no origin is wired, so a covering partial is the only thing that could have served; its sibling pins the decline. `origin_range_pull` pins the miss beside the tier counter that proves a fill ran. And `cache_hit_refused_under_egress_saturation` pins the pre-shed ordering — every other test runs a permissive limiter, so moving the bump inside the admission arm would otherwise pass the whole suite. Also corrects the residual to 22 subtracted counters in the CHANGELOG, matching the panel, and drops changelog voice from a panel description operators read. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The paid serve path streams through
CacheEngine::export_bao_range_streamand never callsCacheEngine::get.decdn_cache_hits_total,decdn_cache_misses_totalanddecdn_cache_bytes_returned_totalare allget-scoped, so on a node serving paying clients they sit at a permanent zero however full its store is.The live fleet shows exactly that. Over 24h across the three nodes:
decdn_bytes_served_totaldecdn_cache_pull_through_bytes_totaldecdn_cache_bytes_returned_totaldecdn_cache_hits_totaldecdn_cache_bytes(stored)So the fleet overview's hit-ratio panel read a permanent 0%, and its headline throughput panel plotted
cache_bytes_returned_totalas "served" — a flat-zero line — while real egress was 170 GB/day. This is the "a name that resolves can still sit at a permanent zero" trap the monitoring gate explicitly does not catch.What
Exporter. Add
decdn_serve_cache_{hit,partial_hit,miss}_total, bumped at the blob-availability gate inhandlers::client::dispatch. Counted ahead of the load-shed admission, so the ratio stays a property of the store rather than of current pressure — a node shedding hard would otherwise report a hit rate that collapses exactly when an operator most needs to read it. Exactly one of the three fires per request reaching the gate; a withdrawn hash (operator evict, corruption quarantine) is refused before it and counts in none.serve_cache_partial_hitis a sibling rather than a fold-in: it is the payoff of partial-holder advertisement (ADR 038 § Serve side), and folding it into the plain hit would hide whether that mechanism carries any traffic. Both are hits for hit-rate purposes.The
get-scoped counters keep their meaning and their XOR contract — the registry rows and the cache crate's operator ratios now say which counter answers which question, instead of pointing operators at the dead one.Dashboards. Overview throughput reads
decdn_bytes_served_total; both hit-ratio panels read the new family. Two panels land that make standing failures legible:rate(decdn_streams_failed_total{direction="inbound"})minus the 22 seller-leg counters that each end exactly one inbound stream (decdn_serve_economics_refused_totalis excluded: it is a per-candidate buyer-leg gate and ends no inbound stream). A standing positive floor is expected (early client close and the free header handshake count as failures by design and have no reason counter), so the panel description says to read the shape, not the level. On the live fleet this evaluates to ~297/day.decdn_serve_stream_rejected_bad_binding_totalanddecdn_node_pull_pool_open_failures_totaljoin the breakdowns they were missing from — the latter is the dominant pull failure cause on the live fleet and was on no panel. Eleven further exported-but-unplotted series (probe read faults, the fee-shares watcher downtime/restart pair, the reconciled-redemption skip, the per-peer rate-limit prune sweeps, the iroh path-composition family) land on their existing panels, taking live-series dashboard coverage from 94% to 100%.Verification
cargo clippy --workspace --all-targets— cleancargo fmt -- --check— cleancargo nextest run -p decdn-node— full suite passes (incl. the 33metricsgate tests and 118client_loopback)RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items— cleanserve_cache_*targets, which have no data until the fleet runs this binary.New behavioural coverage:
assert_one_completed_inbound_streamnow pinsserve_cache_hit_total 1with both siblings at zero, andserve_cache_hit_family_exports_and_recordspins the zero floor plus one bump per recorder.Deploy note
The two hit-ratio panels render
(no data)until the nodes run this binary. Everything else is live on publish. Dashboards are not published yet —monitoring/*.jsonhere is the source of truth to push after merge.Out of scope — filed separately
The live fleet has a node-to-node pull leg failing 100% of attempts, and ~297/day of stream failures no counter names. Both are pre-existing and are what these panels now make visible; issues filed rather than fixed here.
🤖 Generated with Claude Code
Review round 2 (commit
fcc62570)A multi-agent review found the metering placement sound — no bypass, no double-count, no other delivery entry point, all three bumps consistently pre-shed — but several written claims wrong. Corrected:
decdn_cache_misses_totalis notget-scoped. It is also bumped bypopulate/populate_localandpull_through_range, which the serve-path fill tiers call. Onlyhitsandbytes_returnedareget-exclusive, so the pair reads as a populated permanent 0% rather than an empty series. The cache module doc had begun contradicting its own field doc.serve_cache_missdoes not imply a fill tier ran — the bump precedes the shed gate, the floor reservation and thepull_authorizedcheck every tier is gated on, and it absorbs a store fault in the partial-coverage lookup that.ok()?renders as absence.serve_auditstore fault.bytes_servedis the bao wire form over chunk-group-aligned ranges and includes downstream-node egress;pull_through_bytesis raw origin content.serve_economics_refusedis a per-candidate buyer-leg gate that ends no inbound stream, so subtracting it drove the residual structurally low. Caught and fixed before this round.Coverage for the two branches that had none: the partial branch is pinned in
partial_serve.rswhere no origin is wired (a covering partial is the only thing that could have served), its sibling pins the decline,origin_range_pullpins the miss beside the tier counter, andcache_hit_refused_under_egress_saturationpins the pre-shed ordering — every other test runs a permissive limiter, so moving the bump into the admission arm would otherwise pass the whole suite.Verified by mutation: swapping the partial-hit bump to the hit sibling fails the new assertion with
decdn_serve_cache_hit_total should be 0 for a serve_cache_partial_hit classification, got 1. Full suite 1172/1172.