mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
Include native USD in ChatGPT turn cost telemetry (#62810)
## Why When a turn incurs usage priced directly in USD, reporting only the credit-converted estimate understates its cost. ## What changed Sum `estimated_usage_usd_micros` and `native_usage_usd_micros` for settled turns. Default an omitted native USD field to zero for legacy responses. Suppress the total when either component is unavailable (including explicit null), either is negative, or their sum overflows. ## Testing Cover omitted and null native USD values, zero costs, negative amounts, and overflow in backend client tests. Verify that the combined amount reaches the OTLP exporter in the app-server integration test. GitOrigin-RevId: 8709e48329db813cd66baf270ee3f1bcfd87cb03
This commit is contained in:
@@ -53,14 +53,13 @@ impl WorkerRuntime {
|
||||
continue;
|
||||
};
|
||||
let (Some(micros), Some(settled_ids)) =
|
||||
(cost.estimated_usage_usd_micros, cost.settled_response_ids)
|
||||
(cost.visible_total_usd_micros(), cost.settled_response_ids)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
// Missing/hidden dollars are not zero. A projection can appear before
|
||||
// all responses settle, so require every locally observed response.
|
||||
if micros < 0
|
||||
|| entry.expected_response_ids.is_empty()
|
||||
if entry.expected_response_ids.is_empty()
|
||||
|| !entry
|
||||
.expected_response_ids
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user