Emit turn cost telemetry for ChatGPT sessions (#41944)

## What changed

- Query workspace-visible turn estimates for ChatGPT-authenticated sessions through the appropriate Codex or ChatGPT endpoint.
- Track completed response IDs and emit `codex.turn.cost_microusd` only when the estimate is nonnegative, visible, and covers every observed response.
- Keep error response bodies out of turn-cost worker logs.

## Testing

- Cover both endpoint styles, nullable estimates, settlement validation, exact micro-USD conversion, and response-ID tracking.
- Add an app-server integration test that verifies a settled ChatGPT turn reaches the OTLP metrics exporter with its turn, conversation, and auth-mode attributes.

GitOrigin-RevId: 6ae3f8df729fad52984a0c6efafd8c96c7214e55
This commit is contained in:
xli-oai authored and copyberry committed 2026-09-01 00:30:55 +00:00
1 parent 9c7edd4bc3
commit e39ab0c185
10 files changed
+776 -32

No files matched your search

+2
View File
@@ -2,6 +2,8 @@ mod client;
pub(crate) mod types;
pub use client::AddCreditsNudgeCreditType;
pub use client::ChatgptThreadTurnCosts;
pub use client::ChatgptTurnCost;
pub use client::Client;
pub use client::RequestError;
pub use client::ThreadUsage;