mirror of
https://github.com/openai/codex.git
synced 2026-11-05 16:29:31 +00:00
feat: add manual and remote_v2 tags to compaction metric (#24608)
## Why `codex.task.compact` only distinguished `local` vs `remote`, which made it hard to answer simple counter questions in Statsig. Manual `/compact` and automatic compaction were collapsed together, and the legacy remote path was also collapsed with `remote_compaction_v2`. ## What Changed - route `codex.task.compact` through a shared helper in `core/src/tasks/mod.rs` - add a `manual=true|false` tag so manual and automatic compaction can be counted separately - split the remote tag into `remote` and `remote_v2` - emit the metric from the inline auto-compaction path in `core/src/session/turn.rs` as well as the manual `CompactTask` path in `core/src/tasks/compact.rs` - add focused unit coverage for the new tag shapes in `core/src/tasks/mod_tests.rs` ## Verification - added unit coverage in `core/src/tasks/mod_tests.rs` covering manual `remote_v2` tags and automatic `local` tags
This commit is contained in:
1 parent
f6fd753039
commit
9271e84b79
4 files changed
+88
-9
No files matched your search
@@ -62,6 +62,7 @@ pub(crate) use user_shell::UserShellCommandTask;
|
||||
pub(crate) use user_shell::execute_user_shell_command;
|
||||
|
||||
const GRACEFULL_INTERRUPTION_TIMEOUT_MS: u64 = 100;
|
||||
const TASK_COMPACT_METRIC: &str = "codex.task.compact";
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(crate) enum InterruptedTurnHistoryMarker {
|
||||
@@ -145,6 +146,18 @@ fn emit_turn_memory_metric(
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn emit_compact_metric(
|
||||
session_telemetry: &SessionTelemetry,
|
||||
compact_type: &'static str,
|
||||
manual: bool,
|
||||
) {
|
||||
session_telemetry.counter(
|
||||
TASK_COMPACT_METRIC,
|
||||
/*inc*/ 1,
|
||||
&[("type", compact_type), ("manual", bool_tag(manual))],
|
||||
);
|
||||
}
|
||||
|
||||
fn bool_tag(value: bool) -> &'static str {
|
||||
if value { "true" } else { "false" }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user