Repository navigation
feat(logging): consistent fields, throttled peer warns, tx hashes, CLI -v - #2057
Conversation
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]>
There was a problem hiding this comment.
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
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
errorandpeerfields and identity formatting. - Adds warning throttling, swallowed-error diagnostics, and transaction-hash reporting.
- Preserves
RUST_LOGduring reloads and adds-vverbosity 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.
Coverage reportTotal: 82.96% (was 82.97%, ▼ 0.01%) — 80387/96894 lines
History
|
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]>


First of three observability PRs. This one is logging hygiene; traces and metrics+alerts build on it.
What changes
error = %…(was a mix of%err,err = %…,error = %…, ~110 sites). Atracing-field-namespygrep pre-commit hook rejects the other spellings.warn!lines could be fired at any rate by a remote peer and never named it. The deposit-refusal throttle is extracted intoWarnThrottle(crates/node/src/warn_throttle.rs); each of those sites gets its own 1-minute window and logspeer+suppressed. The probe read path logs once in the handler (where the peer is known) instead of once per failure arm.peeris one thing. DHT logs saypeer(wasresponder/seed/ Debug byte arrays).NodeId/ContentHashgain a lowercase-hexDisplayidentical toiroh::PublicKey's, so DHT and transportpeerfields match (public-API snapshot updated).TxOutcome::ReceiptErr/Timeoutcarry the tx hash;redeemManyfailure logs print it.RUST_LOG. A SIGHUP/admin reload used to replace aRUST_LOGfilter with the bare file level (dropping per-target directives, even on an unchanged level on the first reload).RUST_LOGnow wins for the life of the process, as at startup.get, failed stale-record prune.buyer_channelerror fields useformat_args!rather than allocating.-v/-vv/-vvv→ info / debug / trace.--log-level>-v;RUST_LOG> both.Operator-visible: log queries matching
err=need to matcherror=. 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)WarnThrottlewindow + suppressed count,reload_directive, CLIrequested_levelprecedence,NodeIdDisplay-D warnings, doc, new field-name hook) on every commit🤖 Generated with Claude Code