Add reverse RPC and hook callback timing traces - #2439
Conversation
Measure inbound scheduling, hook callback execution, response encoding, writer queue delay, write_all, and flush without exposing callback content or changing RPC behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Capture the forwarding boundary explicitly and key request-derived correlation hashes per client to prevent cross-run linkability or offline session ID guessing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Make reverse-RPC diagnostics opt-in at the tracing target, preserve reconstructible phase placement, and bound timing delivery without affecting response behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Avoid constructing timing infrastructure when collection is disabled, preserve consumer warning-clean builds, and count saturated terminal records once. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bind timing to exact forwarded request generations, preserve forwarding order, and restrict trace labels to privacy-safe values. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
rust/src/jsonrpc.rs — Timing remains active for every outbound JSON-RPC frame even when reverse-RPC tracing was disabled… |
|
rust/src/session.rs — This drain runs before the receiver is closed, while its router sender remains registered until the… |
|
rust/src/jsonrpc.rs — The timing consumer still runs on a Tokio worker, and each debug! call invokes the subscriber… |
What changed in this PR
Adds opt-in reverse JSON-RPC and hook callback timing traces to the Rust SDK.
Changes:
- Correlates inbound requests through routing, dispatch, and response writing.
- Emits bounded timing records for request, hook, encoding, queue, write, flush, and completion phases.
- Adds extensive timing, saturation, cancellation, and redaction tests.
| File | Description |
|---|---|
rust/src/jsonrpc.rs |
Implements timing infrastructure, correlation, emission, and tests. |
rust/src/session.rs |
Propagates traces through session request dispatch. |
rust/src/router.rs |
Routes trace-carrying reverse requests. |
rust/src/lib.rs |
Enables timing-aware client construction and responses. |
rust/src/hooks.rs |
Measures hook callback execution. |
rust/src/github_token.rs |
Preserves traces through token dispatch. |
rust/src/copilot_request_handler.rs |
Preserves traces through inference dispatch. |
rust/Cargo.toml |
Adds timing-test dependencies and features. |
rust/Cargo.lock |
Locks added tracing dependencies. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Remove disabled-path clock reads, close request receivers before shutdown draining, and isolate timing subscribers on the opt-in timing thread. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Ensure timing startup fails closed, synchronize terminal ownership through force-close, and let the dedicated timing thread drain and exit even when handlers retain trace senders. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Thanks for the detailed safety/redaction writeup — that part of the thinking is solid, and we absolutely want to support legitimate diagnostic needs for the GitHub App team. But before we can review the design itself, we need context that isn't in the PR body, commits, or timeline (which currently has zero comments or linked issues):
Once we understand the actual need, we can talk concretely about whether the current ~2,500-line design (and its currently-failing tests, e.g. |
|
Marked as draft for tracking purposes - please set to "ready to review" when applicable. |



Summary
Add opt-in, measurement-only timing for inbound reverse JSON-RPC requests and
SessionHookscallbacks under thegithub_copilot_sdk::reverse_rpc_timingtracing target.The trace separates request forwarding and scheduling, hook callback execution, response encoding, writer queue delay,
write_all, flush, and final completion. Each phase includes a request-relative start offset so consumers can reconstruct the timeline.Safety and behavior
records_droppedrather than delaying RPC work.Validation
cargo +nightly-2026-04-14 fmt --checkcargo clippy --all-features --all-targets -- -D warningscargo test --all-features --libwith 256 tests passingRUSTFLAGS='-D warnings' cargo check --all-featuresIntegration
Consumers must install a tracing subscriber with
github_copilot_sdk::reverse_rpc_timing=debugbefore constructing the SDK client. Enabling the directive later does not add timing infrastructure to an existing client.