Skip to content

feat(logging): consistent fields, throttled peer warns, tx hashes, CLI -v - #2057

Merged
thiras merged 5 commits into
mainfrom
feat/logging-hygiene
Sep 19, 2026
Merged

thiras merged 5 commits into
mainfrom
feat/logging-hygiene

Conversation

@thiras

@thiras thiras commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

First of three observability PRs. This one is logging hygiene; traces and metrics+alerts build on it.

What changes

  • One error field name. Every tracing event names its error error = %… (was a mix of %err, err = %…, error = %…, ~110 sites). A tracing-field-names pygrep pre-commit hook rejects the other spellings.
  • Peer-triggered warns are throttled and carry the peer. The client-binding, unbound-request, unknown-lane and probe read-fault warn! lines could be fired at any rate by a remote peer and never named it. The deposit-refusal throttle is extracted into WarnThrottle (crates/node/src/warn_throttle.rs); each of those sites gets its own 1-minute window and logs peer + suppressed. The probe read path logs once in the handler (where the peer is known) instead of once per failure arm.
  • peer is one thing. DHT logs say peer (was responder / seed / Debug byte arrays). NodeId / ContentHash gain a lowercase-hex Display identical to iroh::PublicKey's, so DHT and transport peer fields match (public-API snapshot updated).
  • Tx hashes survive failures. TxOutcome::ReceiptErr / Timeout carry the tx hash; redeemMany failure logs print it.
  • Reload keeps RUST_LOG. A SIGHUP/admin reload used to replace a RUST_LOG filter with the bare file level (dropping per-target directives, even on an unchanged level on the first reload). RUST_LOG now wins for the life of the process, as at startup.
  • Swallowed errors logged: receipt-log restore after failed rotation, unreadable peer-store record in get, failed stale-record prune.
  • Structured fields instead of interpolated messages (relay probe, keystore password warnings, lock poison); buyer_channel error fields use format_args! rather than allocating.
  • CLI -v / -vv / -vvv → info / debug / trace. --log-level > -v; RUST_LOG > both.

Operator-visible: log queries matching err= need to match error=. CHANGELOG updated.

Test plan

  • cargo nextest run -p decdn-node -p decdn-cli -p decdn-common -p decdn-client-pull -p decdn-protocol -p decdn-cache — 3200 passed (two known-flaky node-origin tests passed on retry)
  • New unit tests: WarnThrottle window + suppressed count, reload_directive, CLI requested_level precedence, NodeId Display
  • pre-commit (fmt, clippy -D warnings, doc, new field-name hook) on every commit

🤖 Generated with Claude Code

thiras and others added 3 commits September 19, 2026 04:15
Tracing events mixed `%err`, `err = %…` and `error = %…` for the same
concept, so a log query or span attribute filter on one name missed
the rest. Rewrite every site to `error = %…` and add a pygrep
pre-commit hook that rejects the other two spellings.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A remote peer could fire the client-binding, unbound-request,
unknown-lane and probe read-fault `warn!` lines at any rate, and none of
them named the peer. Extract the windowed throttle the deposit refusal
log already used into `WarnThrottle`, give each of those call sites its
own window, and carry `peer` and `suppressed` on every admitted line.
The probe read path now logs once in the handler, where the peer is
known, instead of once per failure arm.

DHT logs name the remote id `peer` (was `responder` / `seed`, and
Debug-printed byte arrays). `NodeId` and `ContentHash` gain a
lowercase-hex `Display` that matches `iroh::PublicKey`, so a DHT `peer`
field and a transport `peer` field render the same.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
- `TxOutcome::ReceiptErr` / `Timeout` carry the transaction hash, and
  the redeemMany failure logs print it: a transaction whose receipt
  wait failed may still mine, and its hash is the only way to find it.
- A config reload leaves a `RUST_LOG` filter in place. It used to swap
  it for the bare file `log_level`, silently dropping every per-target
  directive on the first SIGHUP.
- Log the receipt-log restore failure after a failed rotation, an
  unreadable peer-store record in `get`, and a failed stale-record
  prune — all three were dropped with `let _` / `.ok()`.
- Relay-probe, keystore-password and lock-poison logs move their values
  out of the message text into fields. The buyer channel's error fields
  format through `format_args!` instead of allocating a `String`.
- The CLI gains `-v` / `-vv` / `-vvv` (info / debug / trace);
  `--log-level` wins over the count and `RUST_LOG` over both.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 19, 2026 01:43
@thiras thiras self-assigned this Sep 19, 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

Unresolved review findings affect field validation, reload reporting, warning throttling, and probe fault handling.

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

This PR standardizes observability across the workspace with consistent fields, throttled peer warnings, transaction-hash retention, reload handling, and CLI verbosity controls.

Changes:

  • Normalizes error and peer fields and identity formatting.
  • Adds warning throttling, swallowed-error diagnostics, and transaction-hash reporting.
  • Preserves RUST_LOG during reloads and adds -v verbosity controls.
  • Adds validation hooks and changelog documentation.

Review status: Approval is blocked by field-name validation, pinned reload reporting, shared binding throttles, and probe fault handling. Additional findings cover a throttle interval field, missing failure-path tests, and receipt-restore wording.

File Summary
crates/​protocol/​tests/​snapshots/​public_api__public_api.snap Updates the public API snapshot for identity display implementations.
crates/​protocol/​src/​identity.rs Adds lowercase-hex Display implementations.
crates/​node/​src/​warn_throttle.rs Adds reusable windowed warning throttling.
crates/​node/​src/​slash_watcher.rs Normalizes slash watcher error fields.
crates/​node/​src/​runtime/​reload.rs Normalizes reload logging.
crates/​node/​src/​runtime/​mod.rs Structures runtime and relay logs.
crates/​node/​src/​runtime/​eviction.rs Normalizes eviction errors.
crates/​node/​src/​receipt_log.rs Logs failed rotation restoration.
crates/​node/​src/​payment_settlement.rs Standardizes settlement logs and records transaction hashes.
crates/​node/​src/​onchain_tx.rs Preserves hashes through receipt failures and timeouts.
crates/​node/​src/​node_origin/​mod.rs Normalizes node-origin errors.
crates/​node/​src/​metrics.rs Normalizes metrics errors.
crates/​node/​src/​lib.rs Registers the warning-throttle module.
crates/​node/​src/​handlers/​probe.rs Throttles probe read-fault warnings.
crates/​node/​src/​handlers/​dht.rs Formats peer identifiers consistently.
crates/​node/​src/​handlers/​client/​mod.rs Adds client warning-throttle state and refusal logging.
crates/​node/​src/​handlers/​client/​dispatch.rs Adds peer-attributed throttled binding warnings.
crates/​node/​src/​fee_shares_watcher.rs Normalizes watcher errors.
crates/​node/​src/​dht/​publish.rs Standardizes DHT peer fields.
crates/​node/​src/​dht/​lookup.rs Standardizes lookup peer and error fields.
crates/​node/​src/​dht/​chain_projection.rs Structures lock-poison logging fields.
crates/​node/​src/​dht/​chain_origin_directory.rs Normalizes origin lookup errors.
crates/​node/​src/​dht/​capacity_bond_registry.rs Standardizes registry errors.
crates/​node/​src/​dht/​bucket_refresh.rs Standardizes bucket-refresh peer logging.
crates/​node/​src/​dht/​bootstrap.rs Standardizes bootstrap peer logging.
crates/​node/​src/​commands/​mod.rs Preserves RUST_LOG during reloads.
crates/​node/​src/​chain_events/​resumable_watcher.rs Normalizes checkpoint errors.
crates/​node/​src/​chain_events/​multiplexed_poller.rs Normalizes poller errors.
crates/​node/​src/​buyer_channel.rs Uses structured buyer-channel errors.
crates/​node/​src/​blacklist_watcher.rs Normalizes blacklist watcher errors.
crates/​node/​src/​binding_check.rs Normalizes binding-check errors.
crates/​incentive/​src/​buyer_pool_table.rs Normalizes hydration errors.
crates/​common/​src/​cli/​mod.rs Adds counted verbosity flags.
crates/​client-pull/​src/​peer_store.rs Logs unreadable and failed-prune records.
crates/​cli/​src/​main.rs Wires verbosity into CLI logging.
crates/​cli/​src/​logging.rs Implements verbosity precedence and levels.
crates/​cache/​src/​retry.rs Normalizes retry errors.
crates/​cache/​src/​engine.rs Normalizes cache errors.
CHANGELOG.md Documents observability and CLI changes.
.pre-commit-config.yaml Adds tracing field-name validation.

💡 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/commands/mod.rs Resolved
Comment thread crates/node/src/handlers/client/mod.rs Resolved
@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.96% (was 82.97%, ▼ 0.01%) — 80387/96894 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 92.95% 4908/5280 ▼ 0.06%
crates/cache/src/retry.rs 94.92% 187/197 ● 0.00%
crates/cli/src/logging.rs 66.67% 68/102 ▲ +11.40%
crates/cli/src/main.rs 79.63% 43/54 ▲ +0.78%
crates/client-pull/src/peer_store.rs 93.40% 382/409 ▼ 2.04%
crates/common/src/cli/mod.rs 100.00% 3/3 ● 0.00%
crates/incentive/src/buyer_pool_table.rs 90.18% 817/906 ● 0.00%
crates/node/src/admin.rs 92.71% 1005/1084 ▲ +0.01%
crates/node/src/binding_check.rs 61.43% 43/70 ● 0.00%
crates/node/src/blacklist_watcher.rs 74.28% 924/1244 ● 0.00%
crates/node/src/buyer_channel.rs 53.42% 516/966 ● 0.00%
crates/node/src/chain_events/multiplexed_poller.rs 89.92% 1178/1310 ● 0.00%
crates/node/src/chain_events/resumable_watcher.rs 89.81% 194/216 ● 0.00%
crates/node/src/commands/mod.rs 16.67% 16/96 ▲ +16.67%
crates/node/src/dht/bootstrap.rs 85.19% 92/108 ● 0.00%
crates/node/src/dht/bucket_refresh.rs 75.84% 135/178 ● 0.00%
crates/node/src/dht/capacity_bond_registry.rs 84.22% 854/1014 ● 0.00%
crates/node/src/dht/chain_origin_directory.rs 89.35% 302/338 ● 0.00%
crates/node/src/dht/chain_projection.rs 86.81% 79/91 ● 0.00%
crates/node/src/dht/lookup.rs 96.11% 445/463 ● 0.00%
crates/node/src/dht/publish.rs 90.63% 1112/1227 ● 0.00%
crates/node/src/dht/routing.rs 97.72% 343/351 ▲ +0.04%
crates/node/src/fee_shares_watcher.rs 83.33% 135/162 ● 0.00%
crates/node/src/handlers/client/dispatch.rs 80.77% 483/598 ▼ 1.39%
crates/node/src/handlers/client/mod.rs 94.96% 1999/2105 ▲ +0.03%
crates/node/src/handlers/dht.rs 77.04% 292/379 ● 0.00%
crates/node/src/handlers/probe.rs 86.61% 291/336 ▼ 0.22%
crates/node/src/metrics.rs 95.21% 974/1023 ● 0.00%
crates/node/src/node_origin/mod.rs 92.00% 1081/1175 ● 0.00%
crates/node/src/onchain_tx.rs 53.57% 15/28 ▼ 1.98%
crates/node/src/payment_settlement.rs 63.24% 998/1578 ▼ 0.04%
crates/node/src/receipt_log.rs 90.57% 528/583 ▼ 0.91%
crates/node/src/runtime/eviction.rs 85.88% 505/588 ● 0.00%
crates/node/src/runtime/mod.rs 48.16% 1168/2425 ● 0.00%
crates/node/src/runtime/reload.rs 96.91% 1631/1683 ▲ +0.07%
crates/node/src/slash_watcher.rs 59.10% 263/445 ● 0.00%
crates/node/src/warn_throttle.rs 95.60% 87/91 new
crates/protocol/src/identity.rs 100.00% 48/48 ● 0.00%
History
Commit Total Δ vs base
1f79dee 82.96% ▼ 0.01%
790aaab 82.96% ▼ 0.01%
f71850c (HEAD) 82.96% ▼ 0.01%

thiras and others added 2 commits September 19, 2026 05:39
Review on #2057:

- The log-level setter returned `Ok(())` when `RUST_LOG` kept the live
  filter, so the reload recorded the file level as current and
  `admin_v1_reload` reported it as running. The setter now returns a
  `LogLevelApply` (`Installed` / `KeptRustLog`); a kept filter leaves
  the snapshot `None`, as its doc already promised, and the next reload
  asks the setter again.
- The insufficient-deposit warn reported the signer-cap throttle's
  interval; it reports its own.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Multi-agent review of #2057:

- A probe request that fails to read now returns `Ok(())` after closing
  the connection with its code. Returning the `Err` made iroh's router
  log it again, unthrottled, once per bad probe — the throttle was
  bypassed on the one unauthenticated ALPN.
- Throttled gates now sit beside a counter that sees every event:
  `decdn_probe_read_faults_total` and
  `decdn_serve_stream_rejected_bad_binding_total` (both in the ADR
  registry). The other gates already had one.
- `WarnThrottle` reads a monotonic clock, so an NTP or VM clock step can
  neither open the window early nor hold it shut. New test: racing
  callers admit exactly one line and the next line counts every event.
- Receipt log: a rotation after a failed restore re-creates the live
  file instead of shifting backups, which pushed the live inode up the
  chain on every retry until it fell off the end.
- Docs: the RUST_LOG-pinned case in `ReloadSnapshot` and the cached
  level, a test doc moved back onto its test, the shared binding
  window documented as deliberate, CLI logging docs cover `-v`.
- `NodeId` Display is pinned against `iroh::PublicKey`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@thiras
thiras merged commit 5cefb21 into main Sep 19, 2026
25 checks passed
@thiras
thiras deleted the feat/logging-hygiene branch September 19, 2026 03:10
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.

2 participants