Instrument environment and plugin resolution paths (#33223)

## What changed

Add named tracing spans around step environment snapshots, capability and
executor plugin resolution, `AGENTS.md` refreshes, and MCP runtime projection
and refresh operations. Skip recording function arguments to keep these spans
focused on timing and execution flow.

GitOrigin-RevId: 73a452ef1b5da6f7f2b00d24421a815c5d514eaf
This commit is contained in:
rphilizaire-openai authored and copyberry committed 2026-07-15 03:27:16 +00:00
1 parent 3f74f00295
commit 35b33e4304
11 files changed
+12

No files matched your search

+1
View File
@@ -2628,6 +2628,7 @@ dependencies = [
"codex-utils-path-uri", "codex-utils-path-uri",
"serde_json", "serde_json",
"thiserror 2.0.18", "thiserror 2.0.18",
"tracing",
] ]
[[package]] [[package]]
+1
View File
@@ -105,6 +105,7 @@ impl ExecutorPluginProvider {
} }
/// Resolves a plugin and retains the exact filesystem used for package access. /// 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( pub async fn resolve_bound(
&self, &self,
selected_root: &SelectedCapabilityRoot, selected_root: &SelectedCapabilityRoot,
+1
View File
@@ -28,6 +28,7 @@ impl AgentsMdManager {
} }
} }
#[tracing::instrument(name = "agents_md.refresh", skip_all)]
pub(crate) async fn refresh(&self, config: &Config, environments: &TurnEnvironmentSnapshot) { pub(crate) async fn refresh(&self, config: &Config, environments: &TurnEnvironmentSnapshot) {
let selections = environments.to_selections(); let selections = environments.to_selections();
if self.cache.lock().await.selections.as_ref() == Some(&selections) { if self.cache.lock().await.selections.as_ref() == Some(&selections) {
@@ -195,6 +195,7 @@ impl ThreadEnvironments {
.boxed() .boxed()
} }
#[tracing::instrument(name = "environments.snapshot", skip_all)]
pub(crate) async fn snapshot(&self) -> TurnEnvironmentSnapshot { pub(crate) async fn snapshot(&self) -> TurnEnvironmentSnapshot {
let current = self.environments.load_full(); let current = self.environments.load_full();
let mut turn_environments = Vec::with_capacity(current.len()); let mut turn_environments = Vec::with_capacity(current.len());
+1
View File
@@ -100,6 +100,7 @@ impl McpManager {
.config .config
} }
#[tracing::instrument(name = "mcp.runtime_config.project_for_step", skip_all)]
pub(crate) async fn runtime_config_for_step( pub(crate) async fn runtime_config_for_step(
&self, &self,
config: &Config, config: &Config,
+2
View File
@@ -109,6 +109,7 @@ impl Session {
clippy::await_holding_invalid_type, clippy::await_holding_invalid_type,
reason = "MCP runtime comparison and publication must remain serialized" 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( pub(crate) async fn mcp_runtime_for_step(
self: &Arc<Self>, self: &Arc<Self>,
turn_context: &TurnContext, turn_context: &TurnContext,
@@ -319,6 +320,7 @@ impl Session {
.await .await
} }
#[tracing::instrument(name = "mcp.runtime.refresh", skip_all)]
async fn refresh_mcp_servers_inner( async fn refresh_mcp_servers_inner(
&self, &self,
turn_context: &TurnContext, turn_context: &TurnContext,
@@ -118,6 +118,7 @@ impl EnvironmentManager {
/// environment captured for the step carries its exact process-local handle so readiness and /// 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 /// execution cannot come from different registry snapshots. Missing, starting, or failed
/// environments are omitted. A lazy environment is started for a later step. /// 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( pub async fn resolve_selected_capability_roots(
&self, &self,
selected_roots: &[SelectedCapabilityRoot], selected_roots: &[SelectedCapabilityRoot],
+1
View File
@@ -20,3 +20,4 @@ codex-plugin = { workspace = true }
codex-utils-path-uri = { workspace = true } codex-utils-path-uri = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
tracing = { workspace = true }
@@ -31,6 +31,7 @@ pub enum ExecutorPluginConnectorProviderError {
impl ExecutorPluginConnectorProvider { impl ExecutorPluginConnectorProvider {
/// Returns the connector declarations contributed by `plugin`. /// Returns the connector declarations contributed by `plugin`.
#[tracing::instrument(name = "connectors.executor_plugin.declarations.load", skip_all)]
pub async fn load( pub async fn load(
&self, &self,
plugin: &ResolvedExecutorPlugin, plugin: &ResolvedExecutorPlugin,
+1
View File
@@ -58,6 +58,7 @@ impl SelectedExecutorPluginMcpContributor {
/// Successful resolution, including a root that is not a plugin or declares no capabilities, /// 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 /// 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. /// 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( async fn metadata_for_root(
&self, &self,
state: &SelectedExecutorPluginMcpState, state: &SelectedExecutorPluginMcpState,
@@ -48,6 +48,7 @@ pub(super) enum ExecutorPluginMcpProviderError {
impl ExecutorPluginMcpProvider { impl ExecutorPluginMcpProvider {
/// Returns MCP servers declared by `plugin`, bound to its environment. /// 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( pub(super) async fn load(
&self, &self,
plugin: &ResolvedExecutorPlugin, plugin: &ResolvedExecutorPlugin,