mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Add Statsig counters for exec_command latency (#62507)
## Why Dividing total handler time by the call count gives a per-call mean without averaging histogram export batches. ## What changed Record `codex.exec_command.duration_total_ms` and `codex.exec_command.calls` for built-in `exec_command` handler runs, including failures. Measure from handler entry through command exit or the first yield, including shell setup and startup. Exclude calls rejected before the handler runs and retain tags such as `shell_snapshot_mode`, `success`, and `product_sku` when available. ## Testing Cover Statsig export of both counters and check that their counts and duration totals match the tool duration histogram for eligible calls within each tag set. GitOrigin-RevId: 4bf6dc628bca5758999bf0ed5f67051f870a61e8
This commit is contained in:
@@ -705,6 +705,8 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::metrics::API_CALL_COUNT_METRIC;
|
||||
use crate::metrics::API_CALL_DURATION_METRIC;
|
||||
use crate::metrics::EXEC_COMMAND_COUNT_METRIC;
|
||||
use crate::metrics::EXEC_COMMAND_DURATION_TOTAL_METRIC;
|
||||
use crate::metrics::EXEC_SERVER_CLIENT_REQUEST_COUNT_METRIC;
|
||||
use crate::metrics::MetricsExporter;
|
||||
use crate::metrics::RESPONSES_API_ENGINE_IAPI_TTFT_DURATION_METRIC;
|
||||
@@ -895,6 +897,8 @@ mod tests {
|
||||
)?;
|
||||
metrics.counter(TOOL_CALL_COUNT_METRIC, /*inc*/ 1, &[])?;
|
||||
metrics.record_duration(TOOL_CALL_DURATION_METRIC, Duration::from_millis(25), &[])?;
|
||||
metrics.counter(EXEC_COMMAND_DURATION_TOTAL_METRIC, /*inc*/ 25, &[])?;
|
||||
metrics.counter(EXEC_COMMAND_COUNT_METRIC, /*inc*/ 1, &[])?;
|
||||
metrics.counter(TURN_COST_MICROUSD_METRIC, /*inc*/ 1, &[])?;
|
||||
metrics.histogram(TURN_TOKEN_USAGE_METRIC, /*value*/ 100, &[])?;
|
||||
metrics.counter("codex.turns", /*inc*/ 1, &[])?;
|
||||
@@ -909,7 +913,14 @@ mod tests {
|
||||
.collect();
|
||||
names.sort_unstable();
|
||||
names.dedup();
|
||||
assert_eq!(names, vec!["codex.turns"]);
|
||||
assert_eq!(
|
||||
names,
|
||||
vec![
|
||||
EXEC_COMMAND_COUNT_METRIC,
|
||||
EXEC_COMMAND_DURATION_TOTAL_METRIC,
|
||||
"codex.turns"
|
||||
],
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user