From a148a9c44082c55fff64b7d4ef0182dd3d088b3e Mon Sep 17 00:00:00 2001 From: rphilizaire-openai Date: Thu, 11 Jun 2026 16:31:46 -0700 Subject: [PATCH 1/5] [codex] add latency tracing spans --- .../src/request_processors/thread_processor.rs | 8 ++++++++ codex-rs/core-plugins/src/manager.rs | 9 +++++++++ codex-rs/core-skills/src/manager.rs | 9 ++++++++- codex-rs/core/src/session/mod.rs | 8 ++++++++ codex-rs/core/src/session/turn.rs | 3 +++ codex-rs/core/src/session/turn_context.rs | 5 +++++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/codex-rs/app-server/src/request_processors/thread_processor.rs b/codex-rs/app-server/src/request_processors/thread_processor.rs index 813a85fb4d00..193d7a94ed9d 100644 --- a/codex-rs/app-server/src/request_processors/thread_processor.rs +++ b/codex-rs/app-server/src/request_processors/thread_processor.rs @@ -4,6 +4,7 @@ use codex_app_server_protocol::SelectedCapabilityRoot; use codex_extension_api::ExtensionDataInit; use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_DANGER_FULL_ACCESS; use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_WORKSPACE; +use tracing::info_span; const THREAD_LIST_DEFAULT_LIMIT: usize = 25; const THREAD_LIST_MAX_LIMIT: usize = 100; @@ -1001,6 +1002,7 @@ impl ThreadRequestProcessor { let requested_cwd = typesafe_overrides.cwd.clone(); let mut config = config_manager .load_with_overrides(config_overrides.clone(), typesafe_overrides.clone()) + .instrument(info_span!("app_server.thread_start.load_config")) .await .map_err(|err| config_load_error(&err))?; @@ -1065,6 +1067,7 @@ impl ThreadRequestProcessor { typesafe_overrides, /*fallback_cwd*/ None, ) + .instrument(info_span!("app_server.thread_start.load_config")) .await .map_err(|err| config_load_error(&err))?; } @@ -2529,6 +2532,7 @@ impl ThreadRequestProcessor { app_server_client_name.clone(), app_server_client_version.clone(), ) + .instrument(info_span!("app_server.thread_resume.try_running_thread")) .await { Ok(RunningThreadResumeResult::Handled) => return Ok(()), @@ -2563,6 +2567,7 @@ impl ThreadRequestProcessor { let resume_result = if let Some(history) = history { self.resume_thread_from_history(history.as_slice()) + .instrument(info_span!("app_server.thread_resume.load_history")) .await .map(|thread_history| (thread_history, None)) } else if let Some(stored_thread) = stored_thread_from_running_probe { @@ -2571,6 +2576,7 @@ impl ThreadRequestProcessor { .map(|thread_history| (thread_history, Some(*stored_thread))) } else { self.resume_thread_from_rollout(&thread_id, path.as_ref()) + .instrument(info_span!("app_server.thread_resume.load_history")) .await .map(|(thread_history, stored_thread)| (thread_history, Some(stored_thread))) }; @@ -2609,6 +2615,7 @@ impl ThreadRequestProcessor { let config = match self .config_manager .load_for_cwd(request_overrides, typesafe_overrides, history_cwd) + .instrument(info_span!("app_server.thread_resume.load_config")) .await { Ok(config) => config, @@ -2629,6 +2636,7 @@ impl ThreadRequestProcessor { self.auth_manager.clone(), self.request_trace_context(&request_id).await, ) + .instrument(info_span!("app_server.thread_resume.resume_core")) .await { Ok(NewThread { diff --git a/codex-rs/core-plugins/src/manager.rs b/codex-rs/core-plugins/src/manager.rs index 59bf365487b5..8573b0bc41a3 100644 --- a/codex-rs/core-plugins/src/manager.rs +++ b/codex-rs/core-plugins/src/manager.rs @@ -77,6 +77,9 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use std::time::Instant; use tokio::sync::Semaphore; +use tracing::Instrument as _; +use tracing::instrument; +use tracing::trace_span; use tracing::warn; static CURATED_REPO_SYNC_STARTED: AtomicBool = AtomicBool::new(false); @@ -432,6 +435,11 @@ impl PluginsManager { .await } + #[instrument( + level = "trace", + skip_all, + fields(force_reload, plugins_enabled = config.plugins_enabled) + )] pub(crate) async fn plugins_for_config_with_force_reload( &self, config: &PluginsConfigInput, @@ -465,6 +473,7 @@ impl PluginsManager { self.restriction_product, config.remote_plugin_enabled, ) + .instrument(trace_span!("plugins_for_config.load_from_layer_stack")) .await; log_plugin_load_errors(&outcome); self.cache_enabled_outcome_if_current(cache_generation, cache_key, outcome.clone()); diff --git a/codex-rs/core-skills/src/manager.rs b/codex-rs/core-skills/src/manager.rs index 185eaa932060..e52bcd405571 100644 --- a/codex-rs/core-skills/src/manager.rs +++ b/codex-rs/core-skills/src/manager.rs @@ -9,7 +9,10 @@ use codex_protocol::protocol::Product; use codex_protocol::protocol::SkillScope; use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_plugins::PluginSkillRoot; +use tracing::Instrument as _; use tracing::info; +use tracing::instrument; +use tracing::trace_span; use tracing::warn; use crate::SkillLoadOutcome; @@ -100,6 +103,7 @@ impl SkillsManager { /// This path uses a cache keyed by the effective skill-relevant config state rather than just /// cwd so role-local and session-local skill overrides cannot bleed across sessions that happen /// to share a directory. + #[instrument(level = "trace", skip_all)] pub async fn skills_for_config( &self, input: &SkillsLoadInput, @@ -112,7 +116,10 @@ impl SkillsManager { return outcome; } - let outcome = self.build_skill_outcome(roots, &skill_config_rules).await; + let outcome = self + .build_skill_outcome(roots, &skill_config_rules) + .instrument(trace_span!("skills_for_config.build_outcome")) + .await; let mut cache = self .cache_by_config .write() diff --git a/codex-rs/core/src/session/mod.rs b/codex-rs/core/src/session/mod.rs index cc40c6d47d9b..c9a4d19fbca3 100644 --- a/codex-rs/core/src/session/mod.rs +++ b/codex-rs/core/src/session/mod.rs @@ -1308,6 +1308,14 @@ impl Session { } } + #[instrument( + level = "trace", + skip_all, + fields( + thread_id = %self.thread_id(), + rollout_item_count = rollout_items.len() + ) + )] async fn apply_rollout_reconstruction( &self, turn_context: &TurnContext, diff --git a/codex-rs/core/src/session/turn.rs b/codex-rs/core/src/session/turn.rs index 6244274a4044..502086db78e2 100644 --- a/codex-rs/core/src/session/turn.rs +++ b/codex-rs/core/src/session/turn.rs @@ -480,6 +480,7 @@ async fn build_skills_and_plugins( .services .plugins_manager .plugins_for_config(&turn_context.config.plugins_config_input()) + .instrument(trace_span!("build_skills_and_plugins.load_plugins")) .await; // Structured plugin:// mentions are resolved from the current session's // enabled plugins, then converted into turn-scoped guidance below. @@ -494,6 +495,7 @@ async fn build_skills_and_plugins( .mcp_connection_manager .load_full() .list_all_tools() + .instrument(trace_span!("build_skills_and_plugins.list_all_tools")) .or_cancel(cancellation_token) .await { @@ -1134,6 +1136,7 @@ pub(crate) async fn built_tools( let has_mcp_servers = mcp_connection_manager.has_servers(); let all_mcp_tools = mcp_connection_manager .list_all_tools() + .instrument(trace_span!("built_tools.list_all_tools")) .or_cancel(cancellation_token) .await?; let loaded_plugins = sess diff --git a/codex-rs/core/src/session/turn_context.rs b/codex-rs/core/src/session/turn_context.rs index 99d1482c7fc2..0d9ebc8183e1 100644 --- a/codex-rs/core/src/session/turn_context.rs +++ b/codex-rs/core/src/session/turn_context.rs @@ -20,6 +20,8 @@ use codex_sandboxing::policy_transforms::effective_network_sandbox_policy; use codex_utils_path_uri::PathUri; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; +use tracing::instrument; +use tracing::trace_span; #[derive(Clone, Debug)] pub(crate) struct TurnSkillsContext { @@ -728,6 +730,7 @@ impl Session { .await } + #[instrument(name = "turn_context.build", level = "trace", skip_all)] async fn new_turn_context_from_configuration( &self, sub_id: String, @@ -779,6 +782,7 @@ impl Session { .services .plugins_manager .plugins_for_config(&per_turn_config.plugins_config_input()) + .instrument(trace_span!("turn_context.load_plugins")) .await; let effective_skill_roots = plugin_outcome.effective_plugin_skill_roots(); let skills_input = skills_load_input_from_config(&per_turn_config, effective_skill_roots); @@ -788,6 +792,7 @@ impl Session { self.services .skills_manager .skills_for_config(&skills_input, fs) + .instrument(trace_span!("turn_context.load_skills")) .await, ); let mut turn_context: TurnContext = Self::make_turn_context( From 9ebebf0cb0af759667c1bdc5c4aff3df132f890a Mon Sep 17 00:00:00 2001 From: rphilizaire-openai Date: Thu, 11 Jun 2026 17:01:43 -0700 Subject: [PATCH 2/5] [codex] trace stored thread resume history --- codex-rs/app-server/src/request_processors/thread_processor.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/codex-rs/app-server/src/request_processors/thread_processor.rs b/codex-rs/app-server/src/request_processors/thread_processor.rs index 193d7a94ed9d..cc6c5b06ced1 100644 --- a/codex-rs/app-server/src/request_processors/thread_processor.rs +++ b/codex-rs/app-server/src/request_processors/thread_processor.rs @@ -2572,6 +2572,7 @@ impl ThreadRequestProcessor { .map(|thread_history| (thread_history, None)) } else if let Some(stored_thread) = stored_thread_from_running_probe { self.stored_thread_to_initial_history(&stored_thread) + .instrument(info_span!("app_server.thread_resume.load_history")) .await .map(|thread_history| (thread_history, Some(*stored_thread))) } else { From 5c33830e5678a7338b3f0782c481ada594d5be2f Mon Sep 17 00:00:00 2001 From: rphilizaire-openai Date: Thu, 11 Jun 2026 17:29:19 -0700 Subject: [PATCH 3/5] [codex] trace discoverable tool loading --- codex-rs/core-plugins/src/discoverable.rs | 16 ++++++++++++---- codex-rs/core/src/connectors.rs | 7 ++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/codex-rs/core-plugins/src/discoverable.rs b/codex-rs/core-plugins/src/discoverable.rs index a630877f5518..dd23b0ea8713 100644 --- a/codex-rs/core-plugins/src/discoverable.rs +++ b/codex-rs/core-plugins/src/discoverable.rs @@ -6,6 +6,8 @@ use codex_plugin::PluginCapabilitySummary; use std::collections::HashSet; use std::path::Component; use std::path::Path; +use tracing::Instrument; +use tracing::info_span; use tracing::warn; use crate::OPENAI_BUNDLED_MARKETPLACE_NAME; @@ -86,14 +88,17 @@ impl PluginsManager { return Ok(Vec::new()); } - let marketplaces = self - .list_marketplaces_for_config( + let marketplaces = async { + self.list_marketplaces_for_config( &input.plugins, &[], /*include_openai_curated*/ !input.plugins.remote_plugin_enabled, ) - .context("failed to list plugin marketplaces for tool suggestions")? - .marketplaces; + } + .instrument(info_span!("discoverable_plugins.list_marketplaces")) + .await + .context("failed to list plugin marketplaces for tool suggestions")? + .marketplaces; let mut installed_app_connector_ids = self .plugins_for_config(&input.plugins) .await @@ -112,6 +117,7 @@ impl PluginsManager { }; let mut discoverable_plugins = Vec::::new(); + let local_details_span = info_span!("discoverable_plugins.load_local_details"); for marketplace in marketplaces { let marketplace_name = marketplace.name; let use_legacy_local_curated_filter = should_use_legacy_local_curated_discovery_filter( @@ -148,6 +154,7 @@ impl PluginsManager { &marketplace_name, plugin, ) + .instrument(local_details_span.clone()) .await { Ok(plugin) => { @@ -180,6 +187,7 @@ impl PluginsManager { } } } + drop(local_details_span); if let Some(remote_installed_marketplaces) = remote_installed_marketplaces.as_ref() { let installed_remote_plugin_ids = remote_installed_marketplaces .iter() diff --git a/codex-rs/core/src/connectors.rs b/codex-rs/core/src/connectors.rs index cbd738d93cc6..d0bc78da6857 100644 --- a/codex-rs/core/src/connectors.rs +++ b/codex-rs/core/src/connectors.rs @@ -18,6 +18,8 @@ use codex_tools::DiscoverableTool; use rmcp::model::ToolAnnotations; use serde::Deserialize; use tokio_util::sync::CancellationToken; +use tracing::Instrument; +use tracing::info_span; use tracing::warn; use crate::config::Config; @@ -120,7 +122,9 @@ pub(crate) async fn list_tool_suggest_discoverable_tools_with_auth( ) -> anyhow::Result> { let connector_ids = tool_suggest_connector_ids(config, loaded_plugin_app_connector_ids); let directory_connectors = codex_connectors::merge::merge_plugin_connectors( - cached_directory_connectors_for_tool_suggest_with_auth(config, auth).await, + cached_directory_connectors_for_tool_suggest_with_auth(config, auth) + .instrument(info_span!("discoverable_tools.load_connectors")) + .await, connector_ids.iter().cloned(), ); let discoverable_connectors = @@ -138,6 +142,7 @@ pub(crate) async fn list_tool_suggest_discoverable_tools_with_auth( auth, loaded_plugin_app_connector_ids, ) + .instrument(info_span!("discoverable_tools.load_plugins")) .await? .into_iter() .map(DiscoverableTool::from); From 122bcdf2ad64d386aefce7899f4da4ff77bf1ef8 Mon Sep 17 00:00:00 2001 From: rphilizaire-openai Date: Thu, 11 Jun 2026 19:00:36 -0700 Subject: [PATCH 4/5] [codex] remove negligible marketplace span --- codex-rs/core-plugins/src/discoverable.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/codex-rs/core-plugins/src/discoverable.rs b/codex-rs/core-plugins/src/discoverable.rs index dd23b0ea8713..f0505023bcdb 100644 --- a/codex-rs/core-plugins/src/discoverable.rs +++ b/codex-rs/core-plugins/src/discoverable.rs @@ -88,17 +88,14 @@ impl PluginsManager { return Ok(Vec::new()); } - let marketplaces = async { - self.list_marketplaces_for_config( + let marketplaces = self + .list_marketplaces_for_config( &input.plugins, &[], /*include_openai_curated*/ !input.plugins.remote_plugin_enabled, ) - } - .instrument(info_span!("discoverable_plugins.list_marketplaces")) - .await - .context("failed to list plugin marketplaces for tool suggestions")? - .marketplaces; + .context("failed to list plugin marketplaces for tool suggestions")? + .marketplaces; let mut installed_app_connector_ids = self .plugins_for_config(&input.plugins) .await From 6eea710f43558b241c3170bf488bb8a2df20cd54 Mon Sep 17 00:00:00 2001 From: rphilizaire-openai Date: Fri, 12 Jun 2026 14:43:30 -0700 Subject: [PATCH 5/5] [codex] instrument latency methods directly --- AGENTS.md | 4 ++++ codex-rs/app-server/src/config_manager.rs | 2 ++ .../src/request_processors/thread_processor.rs | 13 ++++--------- codex-rs/core-plugins/src/discoverable.rs | 5 ----- codex-rs/core-plugins/src/loader.rs | 2 ++ codex-rs/core-plugins/src/manager.rs | 4 +--- codex-rs/core-skills/src/manager.rs | 8 ++------ codex-rs/core/src/connectors.rs | 9 +++------ codex-rs/core/src/plugins/discoverable.rs | 2 ++ codex-rs/core/src/session/turn.rs | 3 --- codex-rs/core/src/session/turn_context.rs | 3 --- codex-rs/core/src/thread_manager.rs | 2 ++ 12 files changed, 22 insertions(+), 35 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 76eca3bc326b..0c8ce93611ee 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,6 +43,10 @@ In the codex-rs folder where the rust code lives: directory reads, update the crate's `BUILD.bazel` (`compile_data`, `build_script_data`, or test data) or Bazel may fail even when Cargo passes. - Do not create small helper methods that are referenced only once. +- For tracing async work, instrument the function or method definition with + `#[tracing::instrument(...)]` instead of attaching spans to futures with + `.instrument(...)` at call sites. Before adding instrumentation, check whether the callee—or + the implementation method it immediately delegates to—is already instrumented. - Avoid large modules: - Prefer adding new modules instead of growing existing ones. - Target Rust modules under 500 LoC, excluding tests. diff --git a/codex-rs/app-server/src/config_manager.rs b/codex-rs/app-server/src/config_manager.rs index fae113154bfb..d3d7609d6535 100644 --- a/codex-rs/app-server/src/config_manager.rs +++ b/codex-rs/app-server/src/config_manager.rs @@ -21,6 +21,7 @@ use std::path::PathBuf; use std::sync::Arc; use std::sync::RwLock; use toml::Value as TomlValue; +use tracing::instrument; use tracing::warn; /// Shared app-server entry point for loading effective Codex configuration. @@ -212,6 +213,7 @@ impl ConfigManager { .await } + #[instrument(level = "trace", skip_all)] pub(crate) async fn load_with_cli_overrides( &self, cli_overrides: &[(String, TomlValue)], diff --git a/codex-rs/app-server/src/request_processors/thread_processor.rs b/codex-rs/app-server/src/request_processors/thread_processor.rs index cc6c5b06ced1..5c10926858db 100644 --- a/codex-rs/app-server/src/request_processors/thread_processor.rs +++ b/codex-rs/app-server/src/request_processors/thread_processor.rs @@ -4,7 +4,6 @@ use codex_app_server_protocol::SelectedCapabilityRoot; use codex_extension_api::ExtensionDataInit; use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_DANGER_FULL_ACCESS; use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_WORKSPACE; -use tracing::info_span; const THREAD_LIST_DEFAULT_LIMIT: usize = 25; const THREAD_LIST_MAX_LIMIT: usize = 100; @@ -1002,7 +1001,6 @@ impl ThreadRequestProcessor { let requested_cwd = typesafe_overrides.cwd.clone(); let mut config = config_manager .load_with_overrides(config_overrides.clone(), typesafe_overrides.clone()) - .instrument(info_span!("app_server.thread_start.load_config")) .await .map_err(|err| config_load_error(&err))?; @@ -1067,7 +1065,6 @@ impl ThreadRequestProcessor { typesafe_overrides, /*fallback_cwd*/ None, ) - .instrument(info_span!("app_server.thread_start.load_config")) .await .map_err(|err| config_load_error(&err))?; } @@ -2532,7 +2529,6 @@ impl ThreadRequestProcessor { app_server_client_name.clone(), app_server_client_version.clone(), ) - .instrument(info_span!("app_server.thread_resume.try_running_thread")) .await { Ok(RunningThreadResumeResult::Handled) => return Ok(()), @@ -2567,17 +2563,14 @@ impl ThreadRequestProcessor { let resume_result = if let Some(history) = history { self.resume_thread_from_history(history.as_slice()) - .instrument(info_span!("app_server.thread_resume.load_history")) .await .map(|thread_history| (thread_history, None)) } else if let Some(stored_thread) = stored_thread_from_running_probe { self.stored_thread_to_initial_history(&stored_thread) - .instrument(info_span!("app_server.thread_resume.load_history")) .await .map(|thread_history| (thread_history, Some(*stored_thread))) } else { self.resume_thread_from_rollout(&thread_id, path.as_ref()) - .instrument(info_span!("app_server.thread_resume.load_history")) .await .map(|(thread_history, stored_thread)| (thread_history, Some(stored_thread))) }; @@ -2616,7 +2609,6 @@ impl ThreadRequestProcessor { let config = match self .config_manager .load_for_cwd(request_overrides, typesafe_overrides, history_cwd) - .instrument(info_span!("app_server.thread_resume.load_config")) .await { Ok(config) => config, @@ -2637,7 +2629,6 @@ impl ThreadRequestProcessor { self.auth_manager.clone(), self.request_trace_context(&request_id).await, ) - .instrument(info_span!("app_server.thread_resume.resume_core")) .await { Ok(NewThread { @@ -2818,6 +2809,7 @@ impl ThreadRequestProcessor { Some(persisted_metadata) } + #[tracing::instrument(level = "trace", skip_all)] async fn resume_running_thread( &self, request_id: &ConnectionRequestId, @@ -3004,6 +2996,7 @@ impl ThreadRequestProcessor { Ok(RunningThreadResumeResult::NotRunning(None)) } + #[tracing::instrument(level = "trace", skip_all)] async fn resume_thread_from_history( &self, history: &[ResponseItem], @@ -3020,6 +3013,7 @@ impl ThreadRequestProcessor { )) } + #[tracing::instrument(level = "trace", skip_all)] async fn resume_thread_from_rollout( &self, thread_id: &str, @@ -3074,6 +3068,7 @@ impl ThreadRequestProcessor { Ok(stored_thread) } + #[tracing::instrument(level = "trace", skip_all)] async fn stored_thread_to_initial_history( &self, stored_thread: &StoredThread, diff --git a/codex-rs/core-plugins/src/discoverable.rs b/codex-rs/core-plugins/src/discoverable.rs index f0505023bcdb..a630877f5518 100644 --- a/codex-rs/core-plugins/src/discoverable.rs +++ b/codex-rs/core-plugins/src/discoverable.rs @@ -6,8 +6,6 @@ use codex_plugin::PluginCapabilitySummary; use std::collections::HashSet; use std::path::Component; use std::path::Path; -use tracing::Instrument; -use tracing::info_span; use tracing::warn; use crate::OPENAI_BUNDLED_MARKETPLACE_NAME; @@ -114,7 +112,6 @@ impl PluginsManager { }; let mut discoverable_plugins = Vec::::new(); - let local_details_span = info_span!("discoverable_plugins.load_local_details"); for marketplace in marketplaces { let marketplace_name = marketplace.name; let use_legacy_local_curated_filter = should_use_legacy_local_curated_discovery_filter( @@ -151,7 +148,6 @@ impl PluginsManager { &marketplace_name, plugin, ) - .instrument(local_details_span.clone()) .await { Ok(plugin) => { @@ -184,7 +180,6 @@ impl PluginsManager { } } } - drop(local_details_span); if let Some(remote_installed_marketplaces) = remote_installed_marketplaces.as_ref() { let installed_remote_plugin_ids = remote_installed_marketplaces .iter() diff --git a/codex-rs/core-plugins/src/loader.rs b/codex-rs/core-plugins/src/loader.rs index 71f8c42f147f..a89b5e59a533 100644 --- a/codex-rs/core-plugins/src/loader.rs +++ b/codex-rs/core-plugins/src/loader.rs @@ -46,6 +46,7 @@ use std::path::Path; use std::process::Command; use std::sync::Arc; use tempfile::TempDir; +use tracing::instrument; use tracing::warn; const DEFAULT_SKILLS_DIR_NAME: &str = "skills"; @@ -111,6 +112,7 @@ struct PluginAppConfig { category: Option, } +#[instrument(level = "trace", skip_all)] pub async fn load_plugins_from_layer_stack( config_layer_stack: &ConfigLayerStack, extra_plugins: HashMap, diff --git a/codex-rs/core-plugins/src/manager.rs b/codex-rs/core-plugins/src/manager.rs index 8573b0bc41a3..6f7e46f3e9d0 100644 --- a/codex-rs/core-plugins/src/manager.rs +++ b/codex-rs/core-plugins/src/manager.rs @@ -77,9 +77,7 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use std::time::Instant; use tokio::sync::Semaphore; -use tracing::Instrument as _; use tracing::instrument; -use tracing::trace_span; use tracing::warn; static CURATED_REPO_SYNC_STARTED: AtomicBool = AtomicBool::new(false); @@ -473,7 +471,6 @@ impl PluginsManager { self.restriction_product, config.remote_plugin_enabled, ) - .instrument(trace_span!("plugins_for_config.load_from_layer_stack")) .await; log_plugin_load_errors(&outcome); self.cache_enabled_outcome_if_current(cache_generation, cache_key, outcome.clone()); @@ -1197,6 +1194,7 @@ impl PluginsManager { }) } + #[instrument(level = "trace", skip_all)] pub async fn read_plugin_detail_for_marketplace_plugin( &self, config: &PluginsConfigInput, diff --git a/codex-rs/core-skills/src/manager.rs b/codex-rs/core-skills/src/manager.rs index e52bcd405571..f8c5bfd041ec 100644 --- a/codex-rs/core-skills/src/manager.rs +++ b/codex-rs/core-skills/src/manager.rs @@ -9,10 +9,8 @@ use codex_protocol::protocol::Product; use codex_protocol::protocol::SkillScope; use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_plugins::PluginSkillRoot; -use tracing::Instrument as _; use tracing::info; use tracing::instrument; -use tracing::trace_span; use tracing::warn; use crate::SkillLoadOutcome; @@ -116,10 +114,7 @@ impl SkillsManager { return outcome; } - let outcome = self - .build_skill_outcome(roots, &skill_config_rules) - .instrument(trace_span!("skills_for_config.build_outcome")) - .await; + let outcome = self.build_skill_outcome(roots, &skill_config_rules).await; let mut cache = self .cache_by_config .write() @@ -184,6 +179,7 @@ impl SkillsManager { outcome } + #[instrument(level = "trace", skip_all)] async fn build_skill_outcome( &self, roots: Vec, diff --git a/codex-rs/core/src/connectors.rs b/codex-rs/core/src/connectors.rs index d0bc78da6857..85e66450e89d 100644 --- a/codex-rs/core/src/connectors.rs +++ b/codex-rs/core/src/connectors.rs @@ -18,8 +18,7 @@ use codex_tools::DiscoverableTool; use rmcp::model::ToolAnnotations; use serde::Deserialize; use tokio_util::sync::CancellationToken; -use tracing::Instrument; -use tracing::info_span; +use tracing::instrument; use tracing::warn; use crate::config::Config; @@ -122,9 +121,7 @@ pub(crate) async fn list_tool_suggest_discoverable_tools_with_auth( ) -> anyhow::Result> { let connector_ids = tool_suggest_connector_ids(config, loaded_plugin_app_connector_ids); let directory_connectors = codex_connectors::merge::merge_plugin_connectors( - cached_directory_connectors_for_tool_suggest_with_auth(config, auth) - .instrument(info_span!("discoverable_tools.load_connectors")) - .await, + cached_directory_connectors_for_tool_suggest_with_auth(config, auth).await, connector_ids.iter().cloned(), ); let discoverable_connectors = @@ -142,7 +139,6 @@ pub(crate) async fn list_tool_suggest_discoverable_tools_with_auth( auth, loaded_plugin_app_connector_ids, ) - .instrument(info_span!("discoverable_tools.load_plugins")) .await? .into_iter() .map(DiscoverableTool::from); @@ -465,6 +461,7 @@ fn tool_suggest_connector_ids( connector_ids } +#[instrument(level = "trace", skip_all)] async fn cached_directory_connectors_for_tool_suggest_with_auth( config: &Config, auth: Option<&CodexAuth>, diff --git a/codex-rs/core/src/plugins/discoverable.rs b/codex-rs/core/src/plugins/discoverable.rs index fc77ae21e61c..960e244e9712 100644 --- a/codex-rs/core/src/plugins/discoverable.rs +++ b/codex-rs/core/src/plugins/discoverable.rs @@ -5,7 +5,9 @@ use codex_core_plugins::ToolSuggestPluginDiscoveryInput; use codex_login::CodexAuth; use codex_tools::DiscoverablePluginInfo; use std::collections::HashSet; +use tracing::instrument; +#[instrument(level = "trace", skip_all)] pub(crate) async fn list_tool_suggest_discoverable_plugins( config: &Config, plugins_manager: &PluginsManager, diff --git a/codex-rs/core/src/session/turn.rs b/codex-rs/core/src/session/turn.rs index 502086db78e2..6244274a4044 100644 --- a/codex-rs/core/src/session/turn.rs +++ b/codex-rs/core/src/session/turn.rs @@ -480,7 +480,6 @@ async fn build_skills_and_plugins( .services .plugins_manager .plugins_for_config(&turn_context.config.plugins_config_input()) - .instrument(trace_span!("build_skills_and_plugins.load_plugins")) .await; // Structured plugin:// mentions are resolved from the current session's // enabled plugins, then converted into turn-scoped guidance below. @@ -495,7 +494,6 @@ async fn build_skills_and_plugins( .mcp_connection_manager .load_full() .list_all_tools() - .instrument(trace_span!("build_skills_and_plugins.list_all_tools")) .or_cancel(cancellation_token) .await { @@ -1136,7 +1134,6 @@ pub(crate) async fn built_tools( let has_mcp_servers = mcp_connection_manager.has_servers(); let all_mcp_tools = mcp_connection_manager .list_all_tools() - .instrument(trace_span!("built_tools.list_all_tools")) .or_cancel(cancellation_token) .await?; let loaded_plugins = sess diff --git a/codex-rs/core/src/session/turn_context.rs b/codex-rs/core/src/session/turn_context.rs index 0d9ebc8183e1..58764bd4da4a 100644 --- a/codex-rs/core/src/session/turn_context.rs +++ b/codex-rs/core/src/session/turn_context.rs @@ -21,7 +21,6 @@ use codex_utils_path_uri::PathUri; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use tracing::instrument; -use tracing::trace_span; #[derive(Clone, Debug)] pub(crate) struct TurnSkillsContext { @@ -782,7 +781,6 @@ impl Session { .services .plugins_manager .plugins_for_config(&per_turn_config.plugins_config_input()) - .instrument(trace_span!("turn_context.load_plugins")) .await; let effective_skill_roots = plugin_outcome.effective_plugin_skill_roots(); let skills_input = skills_load_input_from_config(&per_turn_config, effective_skill_roots); @@ -792,7 +790,6 @@ impl Session { self.services .skills_manager .skills_for_config(&skills_input, fs) - .instrument(trace_span!("turn_context.load_skills")) .await, ); let mut turn_context: TurnContext = Self::make_turn_context( diff --git a/codex-rs/core/src/thread_manager.rs b/codex-rs/core/src/thread_manager.rs index c332622acbe0..123f89cf8fb4 100644 --- a/codex-rs/core/src/thread_manager.rs +++ b/codex-rs/core/src/thread_manager.rs @@ -78,6 +78,7 @@ use std::sync::atomic::Ordering; use std::time::Duration; use tokio::sync::RwLock; use tokio::sync::broadcast; +use tracing::instrument; use tracing::warn; const THREAD_CREATED_CHANNEL_CAPACITY: usize = 1024; @@ -702,6 +703,7 @@ impl ThreadManager { .await } + #[instrument(level = "trace", skip_all)] pub async fn resume_thread_with_history( &self, config: Config,