codex: keep thread timing conditioning in analytics

This commit is contained in:
Ahmed Ibrahim
2026-05-22 17:54:10 -07:00
parent 253917fc08
commit f49153ee4c
11 changed files with 8 additions and 178 deletions
+1 -7
View File
@@ -17,7 +17,6 @@ use crate::tasks::InterruptedTurnHistoryMarker;
use crate::tasks::interrupted_turn_history_marker;
use crate::thread_start_timing::ThreadStartTiming;
use codex_analytics::AnalyticsEventsClient;
use codex_analytics::ThreadStartType;
use codex_app_server_protocol::ThreadHistoryBuilder;
use codex_app_server_protocol::TurnStatus;
use codex_core_plugins::PluginsManager;
@@ -1190,12 +1189,7 @@ impl ThreadManagerState {
user_shell_override: Option<crate::shell::Shell>,
) -> CodexResult<NewThread> {
let is_resumed_thread = matches!(&initial_history, InitialHistory::Resumed(_));
let mut thread_start_timing = ThreadStartTiming::start(match &initial_history {
InitialHistory::New => ThreadStartType::New,
InitialHistory::Cleared => ThreadStartType::Cleared,
InitialHistory::Forked(_) => ThreadStartType::Forked,
InitialHistory::Resumed(_) => ThreadStartType::Resumed,
});
let mut thread_start_timing = ThreadStartTiming::start();
if let InitialHistory::Resumed(resumed) = &initial_history {
let mut threads = self.threads.write().await;
if let Some(thread) = threads.get(&resumed.conversation_id).cloned() {
+1 -5
View File
@@ -2,11 +2,9 @@ use std::time::Duration;
use std::time::Instant;
use codex_analytics::ThreadStartTimingFact;
use codex_analytics::ThreadStartType;
#[derive(Debug)]
pub(crate) struct ThreadStartTiming {
thread_start_type: ThreadStartType,
phase_started_at: Instant,
prepare_duration: Option<Duration>,
spawn_duration: Option<Duration>,
@@ -14,9 +12,8 @@ pub(crate) struct ThreadStartTiming {
}
impl ThreadStartTiming {
pub(crate) fn start(thread_start_type: ThreadStartType) -> Self {
pub(crate) fn start() -> Self {
Self {
thread_start_type,
phase_started_at: Instant::now(),
prepare_duration: None,
spawn_duration: None,
@@ -42,7 +39,6 @@ impl ThreadStartTiming {
let finalize_duration = self.finalize_duration.unwrap_or_default();
ThreadStartTimingFact {
thread_id,
thread_start_type: self.thread_start_type,
duration_ms: duration_ms(prepare_duration + spawn_duration + finalize_duration),
prepare_duration_ms: duration_ms(prepare_duration),
spawn_duration_ms: duration_ms(spawn_duration),