feat(gateway): add restart trace instrumentation#82396
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: not applicable. this is a new Gateway observability feature, not a broken existing behavior report. The behavior to validate is current-head trace output during restart, and the supplied runtime proof is for an earlier head. Real behavior proof Next step before merge Security Review detailsBest possible solution: If Gateway owners accept the diagnostic surface, land the opt-in trace with the existing docs/tests plus current-head real gateway proof that covers the claimed restart modes or narrows the documented claim. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a new Gateway observability feature, not a broken existing behavior report. The behavior to validate is current-head trace output during restart, and the supplied runtime proof is for an earlier head. Is this the best way to solve the issue? Unclear: the opt-in trace approach matches the existing startup profiling style and keeps default logging unchanged, but the new core env-var contract and respawn-handoff scope need Gateway owner acceptance and current-head proof. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 862be9fb3d6c. |
d69be66 to
3301135
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3301135b82
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
3301135 to
47e3d40
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
47e3d40 to
8129cdd
Compare
|
@clawsweeper re-review |
Summary
OPENCLAW_GATEWAY_RESTART_TRACEsupport for parseable restart trace lines, covering restart signal, active-work drain, close-path phases, next start, ready spans, and memory metrics.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
Behavior addressed: With
OPENCLAW_GATEWAY_RESTART_TRACE=1, a real dev gateway restart now emits parseable restart trace spans and still recovers/healthzand/readyz.Real environment tested: Local macOS checkout on branch
gw-restart-trace-bench, commit8129cdd78a, Nodev24.14.0, builtdist/entry.jsfrom this patch, dev gateway on loopback port19984.Exact steps or command run after this patch: Started
node dist/entry.js --dev gateway run --auth none --bind loopback --port 19984 --force --allow-unconfigured --verbosewithOPENCLAW_GATEWAY_RESTART_TRACE=1 OPENCLAW_NO_RESPAWN=1 FORCE_COLOR=0, probed/healthzand/readyz, sentSIGUSR1, waited for restart trace lines, then probed/healthzand/readyzagain.Evidence after fix:
Observed result after fix: The gateway returned HTTP 200 before and after restart, emitted restart signal, close total, next-start, and ready trace lines, and shut down cleanly after the proof run.
What was not tested: Full-process respawn trace output, Linux/WSL2 runtime proof, and broad Testbox/Crabbox gates.
Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.src/gateway/server-close.test.ts, with existing restart path coverage insrc/cli/gateway-cli/run-loop.test.ts.OPENCLAW_GATEWAY_RESTART_TRACEemits parseable close-path spans and ready child spans without shortening the parent ready span.User-visible / Behavior Changes
When
OPENCLAW_GATEWAY_RESTART_TRACE=1is set, gateway restart logs include parseablerestart trace:lines for drain, close, next-start, and ready timing. Default logging is unchanged when the env var is unset.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
v24.14.0, localdist/entry.js--dev --auth none --bind loopback --port 19984 --allow-unconfigured,OPENCLAW_GATEWAY_RESTART_TRACE=1,OPENCLAW_NO_RESPAWN=1Steps
node scripts/run-vitest.mjs src/gateway/server-close.test.ts src/cli/gateway-cli/run-loop.test.ts.dist/entry.jswith restart tracing enabled./healthzand/readyz.SIGUSR1./healthzand/readyzagain.Expected
Actual
node scripts/run-vitest.mjs src/gateway/server-close.test.ts src/cli/gateway-cli/run-loop.test.ts: passed, 2 files / 45 tests./healthzand/readyz.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) Yes, optionalOPENCLAW_GATEWAY_RESTART_TRACE=1enables restart trace logging.Yes/No) NoRisks and Mitigations
OPENCLAW_GATEWAY_RESTART_TRACE; default behavior is unchanged.