Measure Codex home usage at app-server startup (#41360)

## What changed

- Scan regular files under `CODEX_HOME` in a background blocking task when
  standalone app-server metrics are enabled.
- Record `codex.app_server.codex_home.size_bytes` for the entire home and the
  `sessions` and `archived_sessions` subdirectories.
- Avoid following symlinks, discard incomplete scans, and cancel scanning during
  shutdown.

GitOrigin-RevId: 236fc0a5c156dbd4a99e9835135de194809b4a7b
This commit is contained in:
jif authored and copyberry committed 2026-08-28 16:19:15 +00:00
1 parent 1cc81ca89a
commit f4f85add41
2 files changed
+103

No files matched your search

+10
View File
@@ -96,6 +96,7 @@ mod attestation;
mod auth_mode;
mod bespoke_event_handling;
mod code_mode_host;
mod codex_home_metrics;
mod command_exec;
mod config_layer;
mod config_manager;
@@ -821,6 +822,15 @@ pub async fn run_main_with_transport_options(
}
transport_accept_handles.push(remote_control_accept_handle);
// Only the standalone server measures its local home, not embedded/cloud runtimes.
if let Some(metrics) = otel.as_ref().and_then(codex_otel::OtelProvider::metrics) {
codex_home_metrics::spawn(
config.codex_home.to_path_buf(),
metrics.clone(),
transport_shutdown_token.clone(),
);
}
let otel_reloader_handle = otel_reloader::spawn(
otel,
otel_logger_reload_handle,