mirror of
https://github.com/openai/codex.git
synced 2026-11-28 15:33:11 +00:00
Add process-scoped SQLite telemetry (#22154)
## Summary - add SQLite init, backfill-gate, and fallback telemetry without introducing a cross-cutting state-db access wrapper - install one process-scoped telemetry sink after OTEL startup and let low-level state/rollout paths emit through it directly - add process-start metrics for the process owners that initialize SQLite --------- Co-authored-by: Owen Lin <owen@openai.com>
This commit is contained in:
1 parent
cf6342b75b
commit
b401666ca5
22 files changed
+771
-134
No files matched your search
@@ -450,6 +450,11 @@ impl RolloutRecorder {
|
||||
if state_db_ctx.is_none() {
|
||||
// Keep legacy behavior when SQLite is unavailable: return filesystem results
|
||||
// at the requested page size.
|
||||
codex_state::record_fallback(
|
||||
"list_threads",
|
||||
"db_unavailable",
|
||||
/*telemetry_override*/ None,
|
||||
);
|
||||
return Ok(page_from_filesystem_scan(
|
||||
fs_page,
|
||||
sort_direction,
|
||||
@@ -558,6 +563,11 @@ impl RolloutRecorder {
|
||||
)
|
||||
.await;
|
||||
}
|
||||
codex_state::record_fallback(
|
||||
"list_threads",
|
||||
"metadata_filter",
|
||||
/*telemetry_override*/ None,
|
||||
);
|
||||
let page = page_from_filesystem_scan(fs_page, sort_direction, page_size, sort_key);
|
||||
return Ok(fill_missing_thread_item_metadata_from_state_db(
|
||||
state_db_ctx.as_deref(),
|
||||
@@ -569,6 +579,11 @@ impl RolloutRecorder {
|
||||
}
|
||||
if listing_has_metadata_filters {
|
||||
let page = page_from_filesystem_scan(fs_page, sort_direction, page_size, sort_key);
|
||||
codex_state::record_fallback(
|
||||
"list_threads",
|
||||
"db_error",
|
||||
/*telemetry_override*/ None,
|
||||
);
|
||||
return Ok(fill_missing_thread_item_metadata_from_state_db(
|
||||
state_db_ctx.as_deref(),
|
||||
page,
|
||||
@@ -578,6 +593,7 @@ impl RolloutRecorder {
|
||||
// If SQLite listing still fails, return the filesystem page rather than failing the list.
|
||||
tracing::error!("Falling back on rollout system");
|
||||
tracing::warn!("state db discrepancy during list_threads_with_db_fallback: falling_back");
|
||||
codex_state::record_fallback("list_threads", "db_error", /*telemetry_override*/ None);
|
||||
Ok(page_from_filesystem_scan(
|
||||
fs_page,
|
||||
sort_direction,
|
||||
@@ -601,6 +617,7 @@ impl RolloutRecorder {
|
||||
) -> std::io::Result<Option<PathBuf>> {
|
||||
let codex_home = config.codex_home();
|
||||
let cwd_filter = filter_cwd.map(Path::to_path_buf);
|
||||
let mut fallback_reason = state_db_ctx.is_none().then_some("db_unavailable");
|
||||
if state_db_ctx.is_some() {
|
||||
let mut db_cursor = cursor.cloned();
|
||||
loop {
|
||||
@@ -619,6 +636,7 @@ impl RolloutRecorder {
|
||||
)
|
||||
.await
|
||||
else {
|
||||
fallback_reason = Some("db_error");
|
||||
break;
|
||||
};
|
||||
if let Some(path) =
|
||||
@@ -628,10 +646,18 @@ impl RolloutRecorder {
|
||||
}
|
||||
db_cursor = db_page.next_anchor.map(Into::into);
|
||||
if db_cursor.is_none() {
|
||||
fallback_reason = Some("missing_row");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(reason) = fallback_reason {
|
||||
codex_state::record_fallback(
|
||||
"find_latest_thread_path",
|
||||
reason,
|
||||
/*telemetry_override*/ None,
|
||||
);
|
||||
}
|
||||
|
||||
let mut cursor = cursor.cloned();
|
||||
loop {
|
||||
|
||||
Reference in new issue
Block a user