mirror of
https://github.com/openai/codex.git
synced 2026-10-20 00:18:49 +00:00
Add tracing for project instructions and filesystem sandbox operations (#43913)
## What changed Add tracing spans for `AGENTS.md` discovery and loading, local file reads and metadata lookups, and filesystem sandbox request preparation and execution. Record the instruction byte limit, whether file operations use the sandbox, and the permission entry count during sandbox preparation, while skipping automatic argument capture. GitOrigin-RevId: a6aab1cbac975f8042ce48d6a238c48816f7bd77
This commit is contained in:
@@ -118,6 +118,7 @@ pub(crate) async fn load_project_instructions(
|
||||
/// discovered doc. If no documentation file is found the function returns
|
||||
/// `Ok(None)`. Unexpected I/O failures bubble up as `Err` so callers can
|
||||
/// decide how to handle them.
|
||||
#[tracing::instrument(name = "agents_md.load", skip_all, fields(max_total = max_total))]
|
||||
async fn read_agents_md(
|
||||
config: &Config,
|
||||
fs: &dyn ExecutorFileSystem,
|
||||
@@ -184,6 +185,7 @@ async fn read_agents_md(
|
||||
|
||||
/// Discovers AGENTS.md files from the project root to the current working
|
||||
/// directory, inclusive. Symlinks are allowed.
|
||||
#[tracing::instrument(name = "agents_md.discover", skip_all)]
|
||||
async fn agents_md_paths(
|
||||
config: &Config,
|
||||
cwd: &PathUri,
|
||||
|
||||
@@ -73,6 +73,7 @@ impl FileSystemSandboxRunner {
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(name = "fs.sandbox_request", skip_all)]
|
||||
pub(crate) async fn run(
|
||||
&self,
|
||||
sandbox: &FileSystemSandboxContext,
|
||||
@@ -83,6 +84,11 @@ impl FileSystemSandboxRunner {
|
||||
run_command(command, request_json).await
|
||||
}
|
||||
|
||||
#[tracing::instrument(
|
||||
name = "fs.sandbox_prepare",
|
||||
skip_all,
|
||||
fields(permission_entries = tracing::field::Empty)
|
||||
)]
|
||||
pub(crate) fn sandbox_command(
|
||||
&self,
|
||||
sandbox: &FileSystemSandboxContext,
|
||||
@@ -101,6 +107,7 @@ impl FileSystemSandboxRunner {
|
||||
let native_permissions =
|
||||
native_permissions.materialize_project_roots_with_workspace_roots(workspace_roots);
|
||||
let mut file_system_policy = native_permissions.file_system_sandbox_policy();
|
||||
tracing::Span::current().record("permission_entries", file_system_policy.entries.len());
|
||||
let helper_read_roots = if sandbox.use_legacy_landlock {
|
||||
Vec::new()
|
||||
} else {
|
||||
@@ -324,6 +331,7 @@ fn bazel_bwrap_env_key_is_allowed(_key: &str) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[tracing::instrument(name = "fs.sandbox_execute", skip_all)]
|
||||
async fn run_command(
|
||||
command: SandboxExecRequest,
|
||||
request_json: Vec<u8>,
|
||||
|
||||
@@ -128,6 +128,11 @@ impl LocalFileSystem {
|
||||
file_system.canonicalize(path, sandbox).await
|
||||
}
|
||||
|
||||
#[tracing::instrument(
|
||||
name = "fs.read_file",
|
||||
skip_all,
|
||||
fields(sandboxed = sandbox.is_some_and(FileSystemSandboxContext::should_run_in_sandbox))
|
||||
)]
|
||||
async fn read_file(
|
||||
&self,
|
||||
path: &PathUri,
|
||||
@@ -170,6 +175,11 @@ impl LocalFileSystem {
|
||||
file_system.create_directory(path, options, sandbox).await
|
||||
}
|
||||
|
||||
#[tracing::instrument(
|
||||
name = "fs.get_metadata",
|
||||
skip_all,
|
||||
fields(sandboxed = sandbox.is_some_and(FileSystemSandboxContext::should_run_in_sandbox))
|
||||
)]
|
||||
async fn get_metadata(
|
||||
&self,
|
||||
path: &PathUri,
|
||||
|
||||
Reference in New Issue
Block a user