You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Frontend: getFieldRendererBase() in static/app/utils/discover/fieldRenderers.tsx uses 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 adds gen_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.
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.
sum(gen_ai.cost.total_tokens)$13.82equation|sum(gen_ai.cost.total_tokens) / count_unique(gen_ai.conversation.id)0.152The events API returns
meta.fields="number"for everyequation|...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:
count_unique, or a constant → currencyOther mixes (for example currency ÷ currency) stay a plain number.
Where it happens
get_unit_and_type()insrc/sentry/api/bases/organization_events.pyhandles only rate units inside equations (added in fix(api): Fix rate units not populating for equation fields #108043). All other equations return"number".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
gen_ai.usage.input_tokens, so that Sentry addsgen_ai.cost.total_tokens.sum(gen_ai.cost.total_tokens). It shows$.equation|sum(gen_ai.cost.total_tokens) / count_unique(gen_ai.conversation.id). It shows no$.Related
avg(gen_ai.cost.total_tokens)(about $0.002 per model call) shows as<$0.01. Chart axes show the full value.