Repository navigation
feat(node): telemetry for refuse-to-serve, load-shedding, and warming allowance - #2115
Conversation
…owance
ADR 041's serve-economics refusal, load-shedding, and the per-source
warming allowance were nearly unobservable: the serve-economics refusal
was a single silent counter (no log, no regime split), the load-shed
reason lived only in a debug! line below the default log level, and
warming-allowance blocking was untelemetered entirely. An operator could
not tell a market-too-hot refusal from a config-too-tight one, could not
see which pressure was driving shedding, and could not see warming being
griefed down.
Metrics (sibling counters per the ADR reason-split convention; plain
Counter/Gauge fields auto-export at zero):
- serve-economics: keep decdn_serve_economics_refused_total as the
aggregate, add _warming_total / _amortized_total regime siblings, and
emit a structured debug! at the refusal (candidate rate, ceiling,
regime, source, heat).
- load-shed: decdn_load_shed_refused_{node_at_capacity,egress_saturated,
client_at_capacity}_total, dispatched by an exhaustive match on
ShedReason and wired into the three shed arms in dispatch.rs.
- load-shed concurrency: decdn_load_shed_streams_in_flight gauge, sampled
from the shed controller in the egress-EWMA task.
- warming: decdn_warming_speculative_blocked_total counter (bumped when a
source's allowance is spent and warming is enabled) and
decdn_warming_sources_blocked gauge (read-only refill projection),
sampled beside the egress EWMA.
Observability surfaces (required by the monitoring<->exporter and
ADR<->exporter CI gates in metrics.rs):
- Grafana: a "Refuse-to-serve & load-shedding (ADR 041)" row on the
delivery dashboard (4 panels) and the fleet overview (3 panels). These
live in dashboard-delivery.json, not dashboard-node.json, because every
serve-path metric already sits beside them there.
- Alerts: DecdnServeEconomicsTooTight (amortized regime only — the
warming regime is unactionable), DecdnLoadSheddingUnderPressure (node
+ egress; client_at_capacity is by-design fairness, not alerted, like
signer_floor_at_cap), and DecdnWarmingGriefedDown (info).
- adr/appendix-observability.md registry rows for every new live series.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
WarmingAllowance::available() and blocked_source_count() need to correctly treat warming_budget = 0 as “warming disabled” to avoid incorrect regime selection and misleading blocked-source telemetry under config changes.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Adds end-to-end observability for ADR 041 refusal/load-shed/warming-allowance behavior by introducing new node metrics (including reason/regime splits), wiring them into runtime sampling and serve-path decision points, and surfacing them via Grafana panels + Prometheus alerts + ADR registry entries.
Changes:
- Introduces new
decdn_serve_economics_refused_{warming,amortized}_total,decdn_load_shed_refused_*_total,decdn_load_shed_streams_in_flight, and warming-block telemetry, with matching recorders/tests. - Wires load-shed refusal reason recording and periodic sampling (streams-in-flight + warming blocked count) into the node runtime.
- Updates dashboards, alert rules, and the ADR observability registry to include the new series.
| File | Description |
|---|---|
| monitoring/prometheus-alerts.yml | Adds alerts for serve-economics refusals (amortized), load-shed pressure, and warming grief-cap behavior. |
| monitoring/grafana-dashboard.json | Adds fleet-overview row/panels for ADR 041 refusal/load-shed/warming signals and normalizes em-dash typography. |
| monitoring/dashboard-delivery.json | Adds delivery-dashboard row/panels to break down ADR 041 refusal regimes, load-shed reasons, and concurrency/pressure. |
| crates/node/src/warming_allowance.rs | Adds enabled() and read-only blocked-source counting for warming allowance telemetry (and tests). |
| crates/node/src/runtime/mod.rs | Samples and publishes new gauges (streams-in-flight, warming sources blocked) alongside the egress EWMA task. |
| crates/node/src/node_origin/mod.rs | Emits regime-split serve-economics refusal metrics and structured debug logs; records warming-allowance blocking events. |
| crates/node/src/metrics.rs | Defines new metrics fields, adds regime/reason dispatch recorders, and extends metrics tests/gates. |
| crates/node/src/load_shed/state.rs | Exposes node-wide in-flight count for concurrency gauge sampling. |
| crates/node/src/load_shed/controller.rs | Plumbs node-wide in-flight count through the controller API. |
| crates/node/src/handlers/client/dispatch.rs | Records load-shed refusal reasons at each shed decision site. |
| adr/appendix-observability.md | Registers the new live series in the ADR observability appendix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Copilot review on #2115: with warming_budget=0, enabled() is false but available() still returned true for a never-seen source (None => true), so economic_ceiling would pick the Warming regime and authorize a speculative buy at the market price for a source's first hash — the "zero budget disables warming" semantics only held after each source's first buy created its bucket. And blocked_source_count() still counted spent buckets left over from a prior config, so decdn_warming_sources_blocked would report phantom griefing after a reload to 0. available() now short-circuits to false when !enabled(), and blocked_source_count() returns 0 when !enabled(), so a zero budget disables warming uniformly and keeps the gauge stable across a reload. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 83.71% (was 82.86%, ▲ +0.85%) — 86919/103834 lines
History
|
The load-shed in-flight gauge accessors added for decdn_load_shed_streams_in_flight were exercised only via the runtime sampler, not a unit test. Extend the existing ShedState and LoadShedController tests to assert node_in_flight() tracks acquire/drop and reaches the high-water mark. No behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]>


What & why
ADR 041's serve-economics refusal, load-shedding, and the per-source warming allowance were nearly unobservable:
NotFound, so it never reaches the wire either.NodeAtCapacity/EgressSaturated/ClientAtCapacity) lived only in adebug!below the defaultinfolevel, and the counters collapsed to hit/miss — you couldn't see which pressure was shedding.This closes all three, plus adds the in-flight concurrency gauge, and surfaces everything on Grafana with alerts.
Metrics added
Sibling counters, not labels — per
adr/appendix-observability.md§ "Reason splits: sibling counters, not labels" (each reason has a different remedy;probe_hold_unavailable{reason}is the one documented label exception). PlainCounter/Gaugefields auto-export at zero.decdn_serve_economics_refused_total+_warming_total/_amortized_totaleconomic_ceiling(node_origin) — now also emits a structureddebug!(candidate rate, ceiling, regime, source, heat)decdn_load_shed_refused_{node_at_capacity,egress_saturated,client_at_capacity}_totalhandlers/client/dispatch.rs, via an exhaustivematchonShedReason(compile-gate on new variants)decdn_load_shed_streams_in_flight(gauge)egress_ewmataskdecdn_warming_speculative_blocked_total+decdn_warming_sources_blocked(gauge)economic_ceilingwhen a source's allowance is spent and warming is enabled; gauge is a read-only refill projection sampled beside the egress EWMAObservability surfaces
dashboard-delivery.json, 3 on the fleet overviewgrafana-dashboard.json.prometheus-alerts.yml,decdn-deliverygroup):DecdnServeEconomicsTooTight(amortized regime only — the warming regime is unactionable),DecdnLoadSheddingUnderPressure(node + egress;client_at_capacityis by-design fairness, deliberately not alerted, mirroringsigner_floor_at_cap),DecdnWarmingGriefedDown(info).adr/appendix-observability.mdfor every new live series.Reviewer notes
dashboard-node.json. The node dashboard is host/transport/DHT only; every serve-path metric already lives beside these in the delivery dashboard.metrics.rstie this together:monitoring_selectors_are_exported(everydecdn_name inmonitoring/must be an exported series) andadr_registry_names_are_exported(everyliveADR row must be exported). Both pass.decdn_serve_economics_refused_totalaggregate is kept and its dashboard/alert query is unchanged — the regime siblings are additive.Testing
cargo build,cargo clippy --all-targets --all-features -D warnings,cargo fmt --check, the doc gate (RUSTDOCFLAGS=-D warnings cargo doc), and 138 targeted tests (metrics, warming_allowance, load_shed, node_origin) all green — including the two cross-check gates above and new tests for each metric.🤖 Generated with Claude Code