Problem
The branches view (/traces/branches) shows $0.00 cost for all branches even when sessions with actual cost exist.
Likely root cause
get_branches.sql uses:
COALESCE(SUM(DISTINCT s.estimated_cost_usd), 0) AS total_cost
SUM(DISTINCT ...) on a float column deduplicates by value — two sessions with the same cost (e.g. both $0.00) only count once. This is almost certainly unintentional. For sessions with $0.00 cost (which is common — many sessions have zeroed costs), they all deduplicate to a single $0.00 row, so the sum is still 0.
Fix
Change to:
COALESCE(SUM(s.estimated_cost_usd), 0) AS total_cost
Or use a subquery to get distinct session costs by session ID first.
Investigate
Also verify that estimated_cost_usd is actually populated for sessions on this org — the DISTINCT issue aside, costs may be zero because pricing isn't configured.
Problem
The branches view (
/traces/branches) shows $0.00 cost for all branches even when sessions with actual cost exist.Likely root cause
get_branches.sqluses:SUM(DISTINCT ...)on a float column deduplicates by value — two sessions with the same cost (e.g. both $0.00) only count once. This is almost certainly unintentional. For sessions with $0.00 cost (which is common — many sessions have zeroed costs), they all deduplicate to a single $0.00 row, so the sum is still 0.Fix
Change to:
Or use a subquery to get distinct session costs by session ID first.
Investigate
Also verify that
estimated_cost_usdis actually populated for sessions on this org — theDISTINCTissue aside, costs may be zero because pricing isn't configured.