diff --git a/hive-c0re/src/otel_migrate.rs b/hive-c0re/src/otel_migrate.rs index e7d2342a..0fb8d687 100644 --- a/hive-c0re/src/otel_migrate.rs +++ b/hive-c0re/src/otel_migrate.rs @@ -42,13 +42,13 @@ const TERMINAL_TYPE: &str = "non-interactive"; /// into reasonably-sized OTLP requests rather than one huge body. const MAX_DATAPOINTS_PER_POST: usize = 1000; -/// `claude_code.token.usage` `type` attribute value paired with the -/// `turn_stats` column it maps to (column index in the SELECT below). +/// `claude_code.token.usage` `type` attribute value paired with its +/// position in the per-row `cols` array (built in row order below). const TOKEN_TYPES: &[(&str, usize)] = &[ - ("input", 3), - ("output", 4), - ("cacheRead", 5), - ("cacheCreation", 6), + ("input", 0), + ("output", 1), + ("cacheRead", 2), + ("cacheCreation", 3), ]; /// Datapoints collected from one agent's stats db, split by metric. @@ -201,8 +201,8 @@ fn collect_agent_points(db: &Path, id_prefix: &str) -> Result { })); // token.usage: per (type, model, session.id) running total. - for &(type_, idx) in TOKEN_TYPES { - let val = cols[idx - 3]; + for &(type_, pos) in TOKEN_TYPES { + let val = cols[pos]; if val <= 0 { continue; }