@Override
  public void getMetrics(MetricsCollector collector, boolean all) {
    StartupProgressView prog = startupProgress.createView();
    MetricsRecordBuilder builder = collector.addRecord(
      STARTUP_PROGRESS_METRICS_INFO);

    builder.addCounter(info("ElapsedTime", "overall elapsed time"),
      prog.getElapsedTime());
    builder.addGauge(info("PercentComplete", "overall percent complete"),
      prog.getPercentComplete());

    for (Phase phase: prog.getPhases()) {
      addCounter(builder, phase, "Count", " count", prog.getCount(phase));
      addCounter(builder, phase, "ElapsedTime", " elapsed time",
        prog.getElapsedTime(phase));
      addCounter(builder, phase, "Total", " total", prog.getTotal(phase));
      addGauge(builder, phase, "PercentComplete", " percent complete",
        prog.getPercentComplete(phase));
    }
  }
@Test
  public void testInitialState() {
    MetricsRecordBuilder builder = getMetrics(metrics, true);
    assertCounter("ElapsedTime", 0L, builder);
    assertGauge("PercentComplete", 0.0f, builder);
    assertCounter("LoadingFsImageCount", 0L, builder);
    assertCounter("LoadingFsImageElapsedTime", 0L, builder);
    assertCounter("LoadingFsImageTotal", 0L, builder);
    assertGauge("LoadingFsImagePercentComplete", 0.0f, builder);
    assertCounter("LoadingEditsCount", 0L, builder);
    assertCounter("LoadingEditsElapsedTime", 0L, builder);
    assertCounter("LoadingEditsTotal", 0L, builder);
    assertGauge("LoadingEditsPercentComplete", 0.0f, builder);
    assertCounter("SavingCheckpointCount", 0L, builder);
    assertCounter("SavingCheckpointElapsedTime", 0L, builder);
    assertCounter("SavingCheckpointTotal", 0L, builder);
    assertGauge("SavingCheckpointPercentComplete", 0.0f, builder);
    assertCounter("SafeModeCount", 0L, builder);
    assertCounter("SafeModeElapsedTime", 0L, builder);
    assertCounter("SafeModeTotal", 0L, builder);
    assertGauge("SafeModePercentComplete", 0.0f, builder);
  }