Add process diagnostics snapshots (#37434)

## What changed

- Add a `codex-diagnostics` crate that snapshots the process ID, available
  resident-memory measurements, and registered process-wide gauges.
- Provide guards that update gauges for the lifetime of measured objects.
- Track live `CodexThread` instances with the `core.threads.live` gauge.

## Testing

- Add unit coverage for gauge registration, guard lifetimes, process memory
  snapshots, and live-thread reporting.

GitOrigin-RevId: 3236b086bd4ebe31ed4768ab87a5fa288b0891b0
This commit is contained in:
jif
2026-08-07 11:30:17 +00:00
committed by copyberry
parent 51e36d2ec2
commit a7dcd20d38
9 changed files with 317 additions and 0 deletions
@@ -800,6 +800,12 @@ async fn start_thread_keeps_internal_threads_hidden_from_normal_lookups() {
assert_eq!(manager.list_thread_ids().await, Vec::new());
assert!(manager.get_thread(thread.thread_id).await.is_err());
assert!(
codex_diagnostics::snapshot()
.gauges
.iter()
.any(|gauge| gauge.name == "core.threads.live" && gauge.value > 0)
);
let report = manager
.shutdown_all_threads_bounded(Duration::from_secs(10))