Dashboards: equations lose the unit of their fields ($, duration)
Author: sergicalCreated Sep 17, 2026Updated Sep 17, 2026
LabelsProduct Area: Dashboards
What happens
On a spans dashboard, a plain aggregate of a currency field shows as money. An equation on the same field shows as a plain number.
| Widget query | Shows |
|---|---|
sum(gen_ai.cost.total_tokens) |
$13.82 |
equation|sum(gen_ai.cost.total_tokens) / count_unique(gen_ai.conversation.id) |
0.152 |
The events API returns meta.fields = "number" for every equation|... column, so the widget cannot know that the result is money.
"Cost per run" and "cost per pull request" are the numbers people want most from AI agent traces, and both are equations.
Expected
An equation keeps the unit of its field when the other side has no unit:
- currency ÷ or × a count,
count_unique, or a constant → currency - duration ÷ or × a count or a constant → duration
- currency ± currency → currency; duration ± duration → duration
Other mixes (for example currency ÷ currency) stay a plain number.
Where it happens
- Backend:
get_unit_and_type()insrc/sentry/api/bases/organization_events.pyhandles only rate units inside equations (added in #108043). All other equations return"number". - Frontend:
getFieldRendererBase()instatic/app/utils/discover/fieldRenderers.tsxuses a typed renderer for an equation only when the equation text matches a special field exactly.
Steps to reproduce
- Send spans with
gen_ai.usage.input_tokens, so that Sentry addsgen_ai.cost.total_tokens. - Make a big number widget with
sum(gen_ai.cost.total_tokens). It shows$. - Make a big number widget with
equation|sum(gen_ai.cost.total_tokens) / count_unique(gen_ai.conversation.id). It shows no$.
Related
- Tables show currency with 2 decimals, so
avg(gen_ai.cost.total_tokens)(about $0.002 per model call) shows as<$0.01. Chart axes show the full value. - #112628 (alerts on equations), #68167 (equations in big number widgets).
Source: getsentry/sentry