This is a more broad feature that we want to solve, to let equations have units / data types other then number. We can either let users hardcode this, have some heuristic to determine it (duration * 2 = duration), or both. It's highly related to EXP-879
What happens
A share is always an equation, and Sentry shows it as a raw number with all its decimals.
| Widget query |
Shows |
Wanted |
equation|100 * sum(gen_ai.usage.cache_read.input_tokens) / sum(gen_ai.usage.input_tokens) |
83.6758 |
83.7% |
equation|(sum(gen_ai.usage.input_tokens) - sum(gen_ai.usage.cache_read.input_tokens)) / count() (table column) |
1,635.3072 |
1,635 |
A widget has no setting for the type or the decimal places of an equation, so the only place for "%" is the widget title. Big number thresholds work on the value, but the value still shows without "%".
The prompt cache hit rate is one of the main numbers for AI agent cost, and it is a ratio of two sums.
Expected
One or both of these:
- A per-column setting on a widget query for an equation: output type (number, percentage, currency, duration) and decimal places.
a / b where a and b have the same type is typed as percentage and shows with the existing percentage renderer (formatPercentage in static/app/utils/discover/fieldRenderers.tsx), so users do not need 100 *.
Plain numbers from an equation get a sensible default: at most 2 decimals, or none when the value is above 100.
Steps to reproduce
- Send spans with
gen_ai.usage.input_tokens and gen_ai.usage.cache_read.input_tokens.
- Make a big number widget with
equation|100 * sum(gen_ai.usage.cache_read.input_tokens) / sum(gen_ai.usage.input_tokens).
- It shows
83.6758, with no %, and there is no setting to change this.
Related
This is a more broad feature that we want to solve, to let equations have units / data types other then number. We can either let users hardcode this, have some heuristic to determine it (duration * 2 = duration), or both. It's highly related to EXP-879
What happens
A share is always an equation, and Sentry shows it as a raw number with all its decimals.
equation|100 * sum(gen_ai.usage.cache_read.input_tokens) / sum(gen_ai.usage.input_tokens)83.675883.7%equation|(sum(gen_ai.usage.input_tokens) - sum(gen_ai.usage.cache_read.input_tokens)) / count()(table column)1,635.30721,635A widget has no setting for the type or the decimal places of an equation, so the only place for "%" is the widget title. Big number thresholds work on the value, but the value still shows without "%".
The prompt cache hit rate is one of the main numbers for AI agent cost, and it is a ratio of two sums.
Expected
One or both of these:
a / bwhereaandbhave the same type is typed aspercentageand shows with the existingpercentagerenderer (formatPercentageinstatic/app/utils/discover/fieldRenderers.tsx), so users do not need100 *.Plain numbers from an equation get a sensible default: at most 2 decimals, or none when the value is above 100.
Steps to reproduce
gen_ai.usage.input_tokensandgen_ai.usage.cache_read.input_tokens.equation|100 * sum(gen_ai.usage.cache_read.input_tokens) / sum(gen_ai.usage.input_tokens).83.6758, with no%, and there is no setting to change this.Related
get_unit_and_type()insrc/sentry/api/bases/organization_events.pyreturns"number"for every equation except rates (fix(api): Fix rate units not populating for equation fields #108043).