checkState(servicesByState.put(to, service),
"Service %s in the state map unexpectedly at %s", service, to);
// Update the timer
Stopwatch stopwatch = startupTimers.get(service);
if (from == NEW) {
stopwatch.start();
}
if (to.compareTo(RUNNING) >= 0 && stopwatch.isRunning()) {
// N.B. if we miss the STARTING event then we will never record a startup time.
stopwatch.stop();
if (!(service instanceof NoOpService)) {