Skip to content

feat(node): telemetry for refuse-to-serve, load-shedding, and warming allowance - #2115

Merged
thiras merged 3 commits into
mainfrom
claude/refuse-serve-load-shed-telemetry-0da875
Sep 22, 2026
Merged

thiras merged 3 commits into
mainfrom
claude/refuse-serve-load-shed-telemetry-0da875

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

What & why

ADR 041's serve-economics refusal, load-shedding, and the per-source warming allowance were nearly unobservable:

  • Serve-economics refusal was a single silent counter — no log line, no split — so an operator couldn't tell a market-too-hot refusal (no local fix) from a config-too-tight one (raise your sell rate). The refusal signs the client NotFound, so it never reaches the wire either.
  • Load-shed reason (NodeAtCapacity / EgressSaturated / ClientAtCapacity) lived only in a debug! below the default info level, and the counters collapsed to hit/miss — you couldn't see which pressure was shedding.
  • Warming-allowance blocking was untelemetered entirely — a node being griefed down looked identical to a healthy one.

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). Plain Counter/Gauge fields auto-export at zero.

Series Where it fires
decdn_serve_economics_refused_total + _warming_total / _amortized_total economic_ceiling (node_origin) — now also emits a structured debug! (candidate rate, ceiling, regime, source, heat)
decdn_load_shed_refused_{node_at_capacity,egress_saturated,client_at_capacity}_total the three shed arms in handlers/client/dispatch.rs, via an exhaustive match on ShedReason (compile-gate on new variants)
decdn_load_shed_streams_in_flight (gauge) sampled from the shed controller in the egress_ewma task
decdn_warming_speculative_blocked_total + decdn_warming_sources_blocked (gauge) counter in economic_ceiling when a source's allowance is spent and warming is enabled; gauge is a read-only refill projection sampled beside the egress EWMA

Observability surfaces

  • Grafana: a new "Refuse-to-serve & load-shedding (ADR 041)" row — 4 panels on dashboard-delivery.json, 3 on the fleet overview grafana-dashboard.json.
  • Alerts (prometheus-alerts.yml, decdn-delivery group): DecdnServeEconomicsTooTight (amortized regime only — the warming regime is unactionable), DecdnLoadSheddingUnderPressure (node + egress; client_at_capacity is by-design fairness, deliberately not alerted, mirroring signer_floor_at_cap), DecdnWarmingGriefedDown (info).
  • ADR registry: rows in adr/appendix-observability.md for every new live series.

Reviewer notes

  • Panels went into the delivery dashboard, not dashboard-node.json. The node dashboard is host/transport/DHT only; every serve-path metric already lives beside these in the delivery dashboard.
  • Two CI gates in metrics.rs tie this together: monitoring_selectors_are_exported (every decdn_ name in monitoring/ must be an exported series) and adr_registry_names_are_exported (every live ADR row must be exported). Both pass.
  • The existing decdn_serve_economics_refused_total aggregate 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

…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]>
Copilot AI lite review requested due to automatic review settings September 22, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity · 1 Low severity

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.

Comment thread crates/node/src/warming_allowance.rs Resolved
Comment thread crates/node/src/warming_allowance.rs Resolved
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]>
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 83.71% (was 82.86%, ▲ +0.85%) — 86919/103834 lines

File Coverage Lines Δ
crates/node/src/handlers/client/dispatch.rs 81.55% 526/645 ▼ 3.63%
crates/node/src/load_shed/controller.rs 100.00% 111/111 ● 0.00%
crates/node/src/load_shed/state.rs 100.00% 94/94 ● 0.00%
crates/node/src/metrics.rs 95.39% 1159/1215 ▲ +0.76%
crates/node/src/node_origin/mod.rs 91.40% 1212/1326 ▼ 1.51%
crates/node/src/runtime/mod.rs 47.85% 1168/2441 ▲ +0.23%
crates/node/src/warming_allowance.rs 98.37% 422/429 ▲ +0.16%
History
Commit Total Δ vs base
46d082d 83.69% ● 0.00%
6e3987b (HEAD) 83.71% ▲ +0.85%

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]>
@thiras
thiras merged commit ae659bd into main Sep 22, 2026
25 checks passed
@thiras
thiras deleted the claude/refuse-serve-load-shed-telemetry-0da875 branch September 22, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants