format method

String format(
  1. Object value
)

value as a person reads this signal: a burn rate as 6.7×, a latency in milliseconds, a crash rate or fleet health as a percentage, a count or a metric with no more decimals than it needs.

Text only. What an alert writes into a timeline, a page and a notification is read by a person; a reading's number is untouched.

Implementation

String format(Object value) {
  if (value is Duration) {
    return '${_decimals(value.inMicroseconds / 1000, 1)}ms';
  }
  if (value is! num) return '$value';
  return switch (kind) {
    DVSignalKind.errorBudgetBurn =>
      '${value >= 100 ? value.toStringAsFixed(0) : value.toStringAsFixed(1)}×',
    DVSignalKind.trace => '${_decimals(value, 1)}ms',
    DVSignalKind.crashRate ||
    DVSignalKind.kioskFleetHealth =>
      '${_decimals(value * 100, 2)}%',
    _ => _decimals(value, 2),
  };
}