admin: step down latency units instead of rounding to 0 ms

SeaweedFS latency quantiles are frequently sub-millisecond, so a fixed
millisecond format rendered every axis tick as '0 ms'. Use µs below 1 ms
and add decimals below 10 ms.
This commit is contained in:
Chris Lu
2026-09-14 23:59:38 -07:00
parent 609aab6d8a
commit f7f7505f60
+13 -3
View File
@@ -186,10 +186,20 @@ func FormatChartValue(v float64, unit string) string {
case UnitBytesPS:
return formatChartBytes(v) + "/s"
case UnitSeconds:
if v < 1 {
return fmt.Sprintf("%.0f ms", v*1000)
// Latency quantiles are often sub-millisecond, so step down the unit
// rather than rounding everything to "0 ms".
switch {
case v == 0:
return "0"
case v < 0.001:
return fmt.Sprintf("%.0f µs", v*1e6)
case v < 0.01:
return fmt.Sprintf("%.2f ms", v*1000)
case v < 1:
return fmt.Sprintf("%.1f ms", v*1000)
default:
return fmt.Sprintf("%.2f s", v)
}
return fmt.Sprintf("%.2f s", v)
case UnitPercent:
return fmt.Sprintf("%.0f%%", v)
default: