Skip to content

Dashboards: let an equation show as a percentage and set its decimal places #124679

Description

@sergical

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:

  1. A per-column setting on a widget query for an equation: output type (number, percentage, currency, duration) and decimal places.
  2. 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

  1. Send spans with gen_ai.usage.input_tokens and gen_ai.usage.cache_read.input_tokens.
  2. Make a big number widget with equation|100 * sum(gen_ai.usage.cache_read.input_tokens) / sum(gen_ai.usage.input_tokens).
  3. It shows 83.6758, with no %, and there is no setting to change this.

Related

Activity

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