Skip to content

feat(node): export probe collection latency and time-to-first-byte histograms - #2151

Merged
thiras merged 2 commits into
mainfrom
feat/2047-latency-histograms
Sep 24, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/2047-latency-histograms

Conversation

@thiras

@thiras thiras commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

What

The exporter registered no histograms, so no latency SLO could be written in PromQL. Latency came only from Tempo span durations, which depend on trace sampling, and serve_stream duration grows with blob size. This adds four histograms:

Metric Tier Window
decdn_probe_collection_latency_seconds M (was planned) Start of the concurrent probes (dials included) → end of collection. A round that sends no probe records nothing.
decdn_serve_first_byte_hit_seconds R Decoded request → first ChunkData frame, for serves the availability gate classes as a hit (complete or partial).
decdn_serve_first_byte_miss_seconds R Same window, for serves the gate classes as a miss.
decdn_node_pull_first_byte_seconds R Start of each paid pull leg's open (dial included) → first bao bytes. One record per leg.

It also exercises the _bucket/_sum/_count branch of the registry and monitoring gates against a real histogram for the first time.

Closes #2047

Reviewer notes

  • Serve class comes from the gate, not the loop. A buffered pull-through or local populate fills the store and then serves through the cache-hit deliver, so dispatch.rs fixes one RequestClass at the gate. That same value drives both load-shed admission and the FirstByteClock, so a stream can't be admitted in one class and timed in another.
  • Adopted handshake pulls (PrimedSource) are the subtle part of the pull histogram. The adopting open returns at once, so a clock started there would read about 0. timed_open is the only TimedReader constructor, and PrimedSource<TimedSource<PeerSource>> only accepts a TimedReader, so both handshake sites (mod.rs buffered path, pull_leg.rs predicted first leg) time from before their own open. decdn-client is unchanged.
  • Known shape: on a buffered miss fill the whole blob lands before the first frame, so on that tier the miss series grows with blob size. The ADR row and the dashboard panel say so. The hit series and window-paced misses don't.
  • DecdnMetrics moves from std #[derive(Default)] to #[metrics(default, ...)] because Histogram has no Default. Every other field still gets Default::default().
  • Dashboards: a serve and a pull time-to-first-byte panel on decdn-delivery, and a probe collection latency panel on decdn-node. No alert rule, because there is no agreed SLO threshold yet.
  • Not covered: a TimedReader read-error test. The error returns via ? before anything is recorded, and no test reader in the repo injects an I/O error.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings (exit 0)
  • cargo nextest run -p decdn-node: 1283 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • pre-commit run --all-files
  • Mutation check: hard-coding CacheHit on the buffered-fill deliver path fails bound_client_fetch_triggers_reactive_origin_pull_through and local_populate_serves_own_origin_with_node_to_node_off.
  • contracts/ changed: n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: adr/appendix-observability.md registry rows and latency guidance updated
  • PR title uses an allowed type with a lowercase subject

🤖 Generated with Claude Code

…stograms (#2047)

The exporter registered no histograms, so no latency SLO could be written
in PromQL; latency came only from sampled Tempo span durations, and
serve_stream duration grows with blob size.

Add four iroh-metrics histograms:

- decdn_probe_collection_latency_seconds (M-tier, ADR-specified buckets):
  one probe round's collection window in probe_and_rank. A round that
  sends no probe records nothing.
- decdn_serve_first_byte_{hit,miss}_seconds: decoded request to the first
  ChunkData frame. A one-shot FirstByteClock carries the availability
  gate's RequestClass, so a buffered fill served through deliver still
  records as a miss.
- decdn_node_pull_first_byte_seconds: each paid pull leg, from the start
  of its open to its first bao bytes. TimedSource wraps the node's
  PeerSource; timed_open is the only TimedReader constructor, so an
  adopted header-handshake pull keeps the start of the handshake open.

DecdnMetrics moves to #[metrics(default)] because Histogram has no
Default. The ADR registry rows, the latency guidance, the delivery and
node dashboards, and CHANGELOG are updated.

Closes #2047

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 24, 2026 23:12
@thiras thiras self-assigned this Sep 24, 2026

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

Extend or otherwise document the histogram range so latency quantiles represent tails beyond 30 seconds.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds Prometheus histograms for probe collection latency and serve/pull time-to-first-byte, including dashboards, tests, and documentation.

Changes:

  • Instruments probe, serve, and upstream pull latency.
  • Adds Grafana panels and registry documentation.
  • Extends integration coverage and changelog entries.
  • Moderate finding (2 votes): finite buckets cap at 30 seconds, flattening longer latency quantiles.
File Reviewed changes
monitoring/​dashboard-node.json Adds probe latency panel.
monitoring/​dashboard-delivery.json Adds serve and pull latency panels.
crates/​node/​tests/​partial_serve.rs Tests serve classification.
crates/​node/​tests/​origin_range_pull.rs Tests origin miss timing.
crates/​node/​tests/​node_origin_pull.rs Tests probe and pull observations.
crates/​node/​tests/​client_loopback.rs Tests serve timing behavior.
crates/​node/​src/​node_origin/​timed_source.rs Times upstream pull legs.
crates/​node/​src/​node_origin/​pull_leg.rs Integrates timed pull legs.
crates/​node/​src/​node_origin/​mod.rs Instruments probe and buffered-pull timing.
crates/​node/​src/​metrics.rs Defines and records histograms.
crates/​node/​src/​handlers/​client/​window.rs Propagates timing clocks.
crates/​node/​src/​handlers/​client/​serve_leg.rs Records miss first-byte timing.
crates/​node/​src/​handlers/​client/​dispatch.rs Classifies requests and starts clocks.
crates/​node/​src/​handlers/​client/​delivery.rs Records hit first-byte timing.
CHANGELOG.md Documents observability additions.
adr/​appendix-observability.md Updates metric registry and guidance.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/node/src/metrics.rs Resolved
@github-code-quality

github-code-quality Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 1cfe009 in the feat/2047-latency-hi... branch remains at 85%, unchanged from commit 2647630 in the main branch.

Show a line coverage summary of the most impacted files.
File main 2647630 feat/2047-latency-hi... 1cfe009 +/-
crates/node/src...gin/pull_leg.rs 89% 89% 0%
crates/node/src/metrics.rs 96% 96% 0%
crates/node/src...e_origin/mod.rs 92% 92% 0%
crates/node/src...nt/serve_leg.rs 89% 89% 0%
crates/node/src...ent/delivery.rs 94% 94% 0%
crates/node/src...ent/dispatch.rs 81% 81% 0%
crates/node/src...lient/window.rs 70% 71% +1%
crates/node/src...timed_source.rs 0% 100% +100%

Updated September 24, 2026 23:28 UTC

The time-to-first-byte buckets stopped at 30 s. A cache miss can wait
for discovery (up to 32.5 s alone), a pull leg's open plus a stall
window, and on a buffered fill the whole blob, bounded only by the outer
pull deadline (167.5 s at the default timeouts). Past 30 s every
observation landed in +Inf alone, so histogram_quantile pinned p95/p99
at 30 s exactly where a slow miss matters.

Add 60, 120 and 300 s buckets, and a test that the top bucket exceeds
outer_pull_deadline at the default timeouts, so the ceiling cannot
silently fall behind a default change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@thiras
thiras merged commit 4925d7a into main Sep 24, 2026
30 checks passed
@thiras
thiras deleted the feat/2047-latency-histograms branch September 24, 2026 23:34
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.

observability: no histograms are exported, so no latency SLO is expressible

2 participants