Skip to content

Dashboards: equations lose the unit of their fields ($, duration) #124678

Closed

Description

@sergical

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() in src/sentry/api/bases/organization_events.py handles only rate units inside equations (added in fix(api): Fix rate units not populating for equation fields #108043). All other equations return "number".
  • 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

  1. Send spans with gen_ai.usage.input_tokens, so that Sentry adds gen_ai.cost.total_tokens.
  2. Make a big number widget with sum(gen_ai.cost.total_tokens). It shows $.
  3. Make a big number widget with equation|sum(gen_ai.cost.total_tokens) / count_unique(gen_ai.conversation.id). It shows no $.

Related

Activity

  1. getsantry commented on Sep 17, 2026

    @getsantry
    Contributor

    Assigning to @getsentry/support for routing ⏲️

  2. linear-code commented on Sep 17, 2026

    @linear-code
  3. moved this to Waiting for: Support in GitHub Issues with 👀 3on Sep 17, 2026
  4. getsantry commented on Sep 17, 2026

    @getsantry
    Contributor

    Routing to @getsentry/product-owners-dashboards for triage ⏲️

  5. moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 17, 2026
  6. DominikB2014 commented on Sep 17, 2026

    @DominikB2014
    Contributor

    @sergical this feels very similar to #124679, I think we can close this and just have one issue that's about supporting units in custom equations? (feel free to reopen if i interpreted this wrong!)

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions