Repository navigation
feat(tracing): span the serve, pull, DHT and settlement paths - #2058
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Fix the dashboard query to include all documented spans and distinguish operation names in the legend.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds end-to-end OpenTelemetry tracing for serving, pull-through, DHT, and settlement paths, with updated filtering, resource metadata, documentation, and dashboards.
Changes:
- Adds structured spans and typed serve outcomes.
- Separates OTLP export filtering from log-level filtering.
- Adds correlation fields, tests, documentation, and latency visualization.
| File | Reviewed change |
|---|---|
monitoring/grafana-dashboard.json |
Updates span-rate descriptions. |
monitoring/dashboard-node.json |
Adds latency visualization; query and legend need correction. |
crates/node/src/payment_settlement.rs |
Instruments settlement cycles and transactions. |
crates/node/src/node_origin/mod.rs |
Instruments node pulls and upstream streams. |
crates/node/src/handlers/client/wire.rs |
Adds typed refusal outcomes. |
crates/node/src/handlers/client/window.rs |
Propagates typed serve outcomes. |
crates/node/src/handlers/client/serve_leg.rs |
Records serve outcomes. |
crates/node/src/handlers/client/outcome.rs |
Defines serve outcomes and tests. |
crates/node/src/handlers/client/mod.rs |
Adds fill outcome rendering. |
crates/node/src/handlers/client/fill.rs |
Instruments pull-through fills. |
crates/node/src/handlers/client/dispatch.rs |
Adds inbound stream spans. |
crates/node/src/handlers/client/delivery.rs |
Propagates delivery outcomes. |
crates/node/src/dht/lookup.rs |
Instruments DHT lookups and RPC tasks. |
crates/node/src/commands/otlp.rs |
Adds OTLP filtering and resource metadata. |
crates/node/src/commands/mod.rs |
Makes log filtering per-layer and reloadable. |
crates/client-pull/src/lib.rs |
Instruments progressive pull handshakes. |
crates/cache/src/engine.rs |
Instruments origin and ranged pulls. |
CHANGELOG.md |
Documents tracing additions. |
adr/appendix-observability.md |
Documents span and field conventions. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4 tasks done
thiras
force-pushed
the
feat/trace-spans
branch
2 times, most recently
from
September 19, 2026 03:02
f3b4791 to
a981dd0
Compare
The node exported one span in total, so no request path produced a trace, and the OpenTelemetry layer — which exports events only inside a span — dropped every event on those paths. The log filter also sat on the whole registry, so `log_level = "warn"` silently stopped all export. - Trace export is independent of the log level. The reloadable `EnvFilter` filters the fmt layer only; the OpenTelemetry layer gets a fixed allow-list of deCDN crates at `INFO`, which also keeps the OTLP transport's own spans and iroh's per-packet spans out. The OTLP resource carries `service.version`; the sampler is an explicit `ParentBased(AlwaysOn)`. - `serve_stream` wraps each inbound client stream. Every exit of `serve_stream` returns a typed `ServeEnd` (completed / refused / stopped / reset), so the compiler proves each path names its outcome; the dispatch loop records it once, with `reason` and `bytes`. Stream errors are logged inside the span so they reach the collector. - A miss nests `pull_through` → `origin_pull` → `node_pull` → `upstream_stream` → `open_progressive_pull`. The pull thread carries its caller's span across `spawn_blocking` and its own runtime. - `dht_lookup` (its RPC tasks run in its span), `redeem_cycle` and `onchain_tx` (tx hash + outcome; a halved retry nests). - Both ends of a transfer record `hash`, `pool_id`, `byte_offset`, `peer` and `local_node_id` in identical renderings, so one TraceQL query finds both sides. No trace context crosses the wire: a remote parent would let a peer set this node's sampling decision. - appendix-observability gains a Trace Spans section and the log field conventions; the node dashboard gains a deCDN operation latency panel, and the Tempo panel descriptions stop saying deCDN has no spans. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
thiras
force-pushed
the
feat/trace-spans
branch
from
September 19, 2026 03:13
a981dd0 to
6e581b0
Compare
…them The operation latency panel left out origin_range_pull and redeem_cycle, and its legend (copied from the probe panel) printed only the quantile, so the per-span series were indistinguishable. Review on #2058. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Coverage reportTotal: 83.02% (was 82.97%, ▲ +0.05%) — 80719/97230 lines
History
|
Multi-agent review of #2058: - Bare names in `#[instrument(fields(...))]` expand to `Empty`, not to the argument, so `open_progressive_pull`'s `byte_offset`/`byte_len` — the cross-node join key — `origin_range_pull`'s range, `origin_pull`'s `local_only` and `onchain_tx`'s `depth` were never exported. Each now names its value. - The streaming serve-miss pull runs on its own thread and runtime with no span, so its `open_progressive_pull` started orphan traces. A `serve_miss_pull` child span is entered on that thread. - Failed origin walks, ranged pulls and upstream opens exported as successes: their `err(level = "debug")` event was dropped by the export filter, so nothing set the status. Each records `outcome`, `error` and an error status once; a clean origin miss stays `not_found` with no error status. - The export filter admits WARN/ERROR events from every crate (the OTLP transport stays off), so a dependency failure lands on the deCDN span it happened in. - `serve_stream` records `error` text on a failed stream, `panicked` (then resumes the unwind so the JoinSet still meters it), and `cancelled` when the task is dropped before the stream ends. - `ServeEnd::Reset` names its cause (`stream_cap_full` / `bad_binding`), and refusal reasons record in snake case like every other value. - Tests: the stack `init_tracing` installs is one `subscriber` fn the tests use; a span-capture layer asserts the real serve path records `completed` / `refused cache_miss` with the miss chain under it, and that a node-to-node pull nests `node_pull ⊃ upstream_stream ⊃ open_progressive_pull` across its thread with the range fields set. - Docs: nesting for both miss paths, outcome values, the iroh probe panel removed (the export filter drops iroh spans), dashboard and ADR wording. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
7 of 8 tasks
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.

Second of three observability PRs; #2057 is merged.
Why
The node exported exactly one span, so no request path produced a trace. The OpenTelemetry layer exports events only inside a span, so every event on the serve, pull and payment paths was also dropped. And because the reloadable log filter sat on the whole registry,
log_level = "warn"silently stopped all span export.What changes
EnvFilteris a per-layer filter on the fmt layer; the OTel layer has its own fixed allow-list (deCDN crates atINFO), which also keeps OTLP-transport and iroh per-packet spans out. Tested: aninfospan exports while the fmt filter is atwarn, and the reload handle still swaps the level as a per-layer filter.serve_streamfor each inbound stream.serve_streamand its helpers now return a typedServeEnd(Completed{bytes}/Refused(reason)/Stopped{stop, bytes}/Reset), so the compiler forces every exit to name its outcome; the dispatch loop recordsoutcome/reason/bytesonce (tracing-opentelemetry keeps duplicate attributes if a field is recorded twice). Stream errors are logged inside the span so they reach the collector.pull_through→origin_pull→node_pull→upstream_stream→open_progressive_pull; the pull thread carries its caller's span acrossspawn_blocking+ its own runtime.dht_lookup(RPC tasksin_current_span),redeem_cycle,onchain_tx(tx hash + outcome; halved retries nest).hash,pool_id,byte_offset,peer,local_node_idin identical renderings, so one TraceQL query finds both sides. Atraceparentfield was considered and kept out: the request already carries the join keys, and a remote parent would let a peer set this node's sampling decision.service.version.service.instance.idis left alone — live Tempo shows the host Alloy already sets it (bcl/fra1/lon1) and rewritesservice.nametodecdn-node.quantile_over_timeby span name); Tempo panel descriptions no longer claim deCDN has no spans.Not included: a per-tick span for the chain watchers (a debug span never exports; an info span per watcher per tick would flood the collector).
Test plan
cargo nextest run -p decdn-node -p decdn-client-pull -p decdn-cache -p decdn-cli— 2579 passed (includes the monitoring/ADR metric-name gates)serve_streamspan exports join keys + outcome in the exact renderings the requester side uses; stopped/refused reasons; export filter (deCDN info in, deps and debug out); log level does not filter export; resource attributes; per-layer reload swap-D warnings --all-targets, doc, fmt via pre-commit{resource.service.name="decdn-node" && name="serve_stream"}in Tempo shows both sides of a miss pull, joinable onhash+peer/local_node_id🤖 Generated with Claude Code