From e1cb5d7d962416933e613c08c783cb363315b996 Mon Sep 17 00:00:00 2001 From: qpismont Date: Sun, 26 Jul 2026 11:41:58 +0000 Subject: [PATCH] fix usd metric --- src/bot_actions/review.rs | 2 +- src/metrics.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bot_actions/review.rs b/src/bot_actions/review.rs index 534dd3d..c156aa2 100644 --- a/src/bot_actions/review.rs +++ b/src/bot_actions/review.rs @@ -46,7 +46,7 @@ pub async fn exec_review( review_result.cost = chat_result.cost; if let Some(cost) = review_result.cost { - metrics::openrouter_cost_usd((cost / 100.0).round() as u64); + metrics::openrouter_cost_usd(cost); } let final_review_markdown = review_result_to_markdown(&review_result); diff --git a/src/metrics.rs b/src/metrics.rs index 38c35d9..23698d8 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -35,8 +35,8 @@ pub fn task_failed(event_type: &str) { .increment(1); } -pub fn openrouter_cost_usd(cost: u64) { - counter!("herald_openrouter_cost_usd_total").increment(cost); +pub fn openrouter_cost_usd(cost: f64) { + counter!("herald_openrouter_cost_cents_total").increment((cost * 100.0).round() as u64); } pub fn describe() { @@ -46,7 +46,7 @@ pub fn describe() { describe_gauge!("herald_bot_tasks_active", Unit::Count, "Bot tasks currently in progress"); describe_counter!("herald_bot_tasks_completed_total", Unit::Count, "Bot tasks completed successfully"); describe_counter!("herald_bot_tasks_failed_total", Unit::Count, "Bot tasks that failed"); - describe_counter!("herald_openrouter_cost_usd_total", Unit::Count, "Total OpenRouter cost in USD"); + describe_counter!("herald_openrouter_cost_cents_total", Unit::Count, "Total OpenRouter cost in cents (divide by 100 for USD)"); } pub fn install(bind_addr: &str) -> anyhow::Result<()> {