Add WebSocket connection metrics with reauthentication labels (#59018)

## What changed

- Record connection attempts and durations as `codex.websocket.connect` and `codex.websocket.connect.duration_ms`, labeled with `success`, `reauth`, and the configured `product_sku` when present.
- Detect reauthentication by comparing the current auth revision with the last successful connection, preserving that revision across connection resets. Include `auth.reauth` in connection logs and traces.
- Populate session telemetry with the configured product SKU.

## Testing

Extend tests to check reauthentication labels after account switches, product SKU labels for restored sessions, and failed-handshake counts, durations, and labels.

GitOrigin-RevId: 53a38b4460ab9021058dfe2fe104d0441993b18a
This commit is contained in:
Ben Romano
2026-11-03 00:59:43 +00:00
committed by copyberry
parent c60cda34a3
commit dec38fc9bb
6 changed files with 123 additions and 25 deletions
+1
View File
@@ -1396,6 +1396,7 @@ impl Session {
session_configuration.session_source.clone(),
)
.with_auth_env(auth_env_telemetry.to_otel_metadata())
.with_product_sku(config.apps_mcp_product_sku.as_deref())
.with_user_id(telemetry_auth.and_then(CodexAuth::get_chatgpt_user_id))
.with_tool_result_log_config(config.otel.tool_result);
if !config.otel.log_sse_deltas {