Ratio with its denominator 99.9% of ten requests is one failure. The denominator is what makes a rate readable, and it is the first thing dropped when a tile gets tight. Tokens this needs: --foreground, --muted, --muted-foreground, --border, --chart-1 ──────────────────────────────────────────────────────────────────────── // Rate.tsx ──────────────────────────────────────────────────────────────────────── /** * A rate without its denominator is not a measurement. * * 99.9% over ten requests and 99.9% over four million are different claims, and * only one of them survives a single bad minute. `of` is required, and below a * threshold the component says the number is thin rather than letting a viewer * read it as precision. */ export function Rate({ numerator, of, label, unit, minReliable = 100, }: { numerator: number; of: number; label: string; /** What is being counted: "requests", "sessions". */ unit?: string; minReliable?: number; }) { const pct = of === 0 ? null : (numerator / of) * 100; const thin = of < minReliable; return (
{label}
{/* Two decimals at both ends. 99.95% and 0.04% are the rates people act on, and one decimal rounds both to a lie. */} {pct === null ? "—" : `${pct.toFixed(pct > 99 || pct < 1 ? 2 : 1)}%`}
{numerator.toLocaleString()} of {of.toLocaleString()}{unit ? ` ${unit}` : ""} {thin && · small sample}
Last 5 minutes