mirror of
https://github.com/openai/codex.git
synced 2026-09-16 12:13:30 +00:00
## What changed - Record `exec_server_client_requests_total` for every client RPC call attempt, labeled by protocol method. - Count attempts before local admission so rejected, timed-out, cancelled, and transport-failed calls are included, while notifications and responses are not. - Export the counter to configured OpenTelemetry collectors while excluding it from the built-in Statsig metrics set. ## Testing - Cover every RPC call entry point, successful responses, local and transport failures, timeouts, cancellation, notifications, and disabled metrics. - Verify that the OTLP HTTP exporter retains the counter. GitOrigin-RevId: d266e840d5871aa2c34bed8ce44f3345e2b4650f
24 lines
872 B
Rust
24 lines
872 B
Rust
//! Caller-side RPC attempt counts using the client's protocol method names, independent of tracing.
|
|
|
|
use codex_otel::EXEC_SERVER_CLIENT_REQUEST_COUNT_METRIC;
|
|
use codex_otel::MetricsClient;
|
|
|
|
pub(crate) fn record_client_request(metrics: Option<&MetricsClient>, method: &str) {
|
|
let Some(metrics) = metrics else {
|
|
return;
|
|
};
|
|
// Record before local admission so failures and cancelled calls still count
|
|
// as attempts. Notifications and responses never enter these call paths.
|
|
if metrics
|
|
.counter_with_description(
|
|
EXEC_SERVER_CLIENT_REQUEST_COUNT_METRIC,
|
|
"Total number of client-side exec-server RPC attempts, including local failures.",
|
|
/*inc*/ 1,
|
|
&[("method", method)],
|
|
)
|
|
.is_err()
|
|
{
|
|
tracing::warn!("failed to emit exec-server client request counter");
|
|
}
|
|
}
|