Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Instrument environment and plugin resolution paths (#33223)

rphilizaire-openai35b33e4304a2
diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock
index 98e5031426..8444142e0c 100644
--- a/codex-rs/Cargo.lock
+++ b/codex-rs/Cargo.lock
@@ -2628,6 +2628,7 @@ dependencies = [
"codex-utils-path-uri",
"serde_json",
"thiserror 2.0.18",
+ "tracing",
]
[[package]]
diff --git a/codex-rs/core-plugins/src/provider.rs b/codex-rs/core-plugins/src/provider.rs
index 5a371b3d2e..41484206c8 100644
--- a/codex-rs/core-plugins/src/provider.rs
+++ b/codex-rs/core-plugins/src/provider.rs
@@ -105,6 +105,7 @@ impl ExecutorPluginProvider {
}
/// Resolves a plugin and retains the exact filesystem used for package access.
+ #[tracing::instrument(name = "plugins.executor.package.resolve", skip_all)]
pub async fn resolve_bound(
&self,
selected_root: &SelectedCapabilityRoot,
diff --git a/codex-rs/core/src/agents_md_manager.rs b/codex-rs/core/src/agents_md_manager.rs
index 1e3a3f291d..0218f2b16b 100644
--- a/codex-rs/core/src/agents_md_manager.rs
+++ b/codex-rs/core/src/agents_md_manager.rs
@@ -28,6 +28,7 @@ impl AgentsMdManager {
}
}
+ #[tracing::instrument(name = "agents_md.refresh", skip_all)]
pub(crate) async fn refresh(&self, config: &Config, environments: &TurnEnvironmentSnapshot) {
let selections = environments.to_selections();
if self.cache.lock().await.selections.as_ref() == Some(&selections) {
diff --git a/codex-rs/core/src/environment_selection.rs b/codex-rs/core/src/environment_selection.rs
index 53857e596e..893ad0e885 100644
--- a/codex-rs/core/src/environment_selection.rs
+++ b/codex-rs/core/src/environment_selection.rs
@@ -195,6 +195,7 @@ impl ThreadEnvironments {
.boxed()
}
+ #[tracing::instrument(name = "environments.snapshot", skip_all)]
pub(crate) async fn snapshot(&self) -> TurnEnvironmentSnapshot {
let current = self.environments.load_full();
let mut turn_environments = Vec::with_capacity(current.len());
diff --git a/codex-rs/core/src/mcp.rs b/codex-rs/core/src/mcp.rs
index 4d0e30f99f..399a0912a3 100644
--- a/codex-rs/core/src/mcp.rs
+++ b/codex-rs/core/src/mcp.rs
@@ -100,6 +100,7 @@ impl McpManager {
.config
}
+ #[tracing::instrument(name = "mcp.runtime_config.project_for_step", skip_all)]
pub(crate) async fn runtime_config_for_step(
&self,
config: &Config,
diff --git a/codex-rs/core/src/session/mcp.rs b/codex-rs/core/src/session/mcp.rs
index 32bbf036f9..61f967d955 100644
--- a/codex-rs/core/src/session/mcp.rs
+++ b/codex-rs/core/src/session/mcp.rs
@@ -109,6 +109,7 @@ impl Session {
clippy::await_holding_invalid_type,
reason = "MCP runtime comparison and publication must remain serialized"
)]
+ #[tracing::instrument(name = "mcp.runtime.resolve_for_step", skip_all)]
pub(crate) async fn mcp_runtime_for_step(
self: &Arc<Self>,
turn_context: &TurnContext,
@@ -319,6 +320,7 @@ impl Session {
.await
}
+ #[tracing::instrument(name = "mcp.runtime.refresh", skip_all)]
async fn refresh_mcp_servers_inner(
&self,
turn_context: &TurnContext,
diff --git a/codex-rs/exec-server/src/resolved_capability.rs b/codex-rs/exec-server/src/resolved_capability.rs
index f1fa92c2f0..19a413c4d5 100644
--- a/codex-rs/exec-server/src/resolved_capability.rs
+++ b/codex-rs/exec-server/src/resolved_capability.rs
@@ -118,6 +118,7 @@ impl EnvironmentManager {
/// environment captured for the step carries its exact process-local handle so readiness and
/// execution cannot come from different registry snapshots. Missing, starting, or failed
/// environments are omitted. A lazy environment is started for a later step.
+ #[tracing::instrument(name = "capability_roots.resolve", skip_all)]
pub async fn resolve_selected_capability_roots(
&self,
selected_roots: &[SelectedCapabilityRoot],
diff --git a/codex-rs/ext/connectors/Cargo.toml b/codex-rs/ext/connectors/Cargo.toml
index 1103ae4e2b..044d8264b2 100644
--- a/codex-rs/ext/connectors/Cargo.toml
+++ b/codex-rs/ext/connectors/Cargo.toml
@@ -20,3 +20,4 @@ codex-plugin = { workspace = true }
codex-utils-path-uri = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
+tracing = { workspace = true }
diff --git a/codex-rs/ext/connectors/src/executor_plugin.rs b/codex-rs/ext/connectors/src/executor_plugin.rs
index c27ae3ac62..0436c5429b 100644
--- a/codex-rs/ext/connectors/src/executor_plugin.rs
+++ b/codex-rs/ext/connectors/src/executor_plugin.rs
@@ -31,6 +31,7 @@ pub enum ExecutorPluginConnectorProviderError {
impl ExecutorPluginConnectorProvider {
/// Returns the connector declarations contributed by `plugin`.
+ #[tracing::instrument(name = "connectors.executor_plugin.declarations.load", skip_all)]
pub async fn load(
&self,
plugin: &ResolvedExecutorPlugin,
diff --git a/codex-rs/ext/mcp/src/executor_plugin.rs b/codex-rs/ext/mcp/src/executor_plugin.rs
index 98cfcd3615..3597e100d8 100644
--- a/codex-rs/ext/mcp/src/executor_plugin.rs
+++ b/codex-rs/ext/mcp/src/executor_plugin.rs
@@ -58,6 +58,7 @@ impl SelectedExecutorPluginMcpContributor {
/// Successful resolution, including a root that is not a plugin or declares no capabilities,
/// is cached until the thread state is dropped. Environment availability never invalidates
/// this cache; it only controls whether the cached metadata is projected into a model step.
+ #[tracing::instrument(name = "mcp.executor_plugin.metadata.load", skip_all)]
async fn metadata_for_root(
&self,
state: &SelectedExecutorPluginMcpState,
diff --git a/codex-rs/ext/mcp/src/executor_plugin/provider.rs b/codex-rs/ext/mcp/src/executor_plugin/provider.rs
index a6972df096..58b5e9f63b 100644
--- a/codex-rs/ext/mcp/src/executor_plugin/provider.rs
+++ b/codex-rs/ext/mcp/src/executor_plugin/provider.rs
@@ -48,6 +48,7 @@ pub(super) enum ExecutorPluginMcpProviderError {
impl ExecutorPluginMcpProvider {
/// Returns MCP servers declared by `plugin`, bound to its environment.
+ #[tracing::instrument(name = "mcp.executor_plugin.servers.load", skip_all)]
pub(super) async fn load(
&self,
plugin: &ResolvedExecutorPlugin,