Refactor spawn stat computation.

This should be a no-op change that will allow us more easily to expose the
different runners to the build metrics in the BEP.

PiperOrigin-RevId: 344808222
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
index b7eaaf1..daad07a 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
@@ -14,6 +14,7 @@
 package com.google.devtools.build.lib.runtime;
 
 import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.eventbus.AllowConcurrentEvents;
 import com.google.common.eventbus.EventBus;
 import com.google.common.eventbus.Subscribe;
@@ -169,9 +170,10 @@
         }
       }
 
-      String spawnSummary = spawnStats.getSummary();
+      ImmutableMap<String, Integer> spawnSummary = spawnStats.getSummary();
+      String spawnSummaryString = SpawnStats.convertSummaryToString(spawnSummary);
       if (statsSummary) {
-        reporter.handle(Event.info(spawnSummary));
+        reporter.handle(Event.info(spawnSummaryString));
         reporter.handle(
             Event.info(
                 String.format(
@@ -191,11 +193,13 @@
                     executionTime / 1000.0)));
       } else {
         reporter.handle(Event.info(Joiner.on(", ").join(items)));
-        reporter.handle(Event.info(spawnSummary));
+        reporter.handle(Event.info(spawnSummaryString));
       }
 
-      event.getResult().getBuildToolLogCollection()
-          .addDirectValue("process stats", spawnSummary.getBytes(StandardCharsets.UTF_8));
+      event
+          .getResult()
+          .getBuildToolLogCollection()
+          .addDirectValue("process stats", spawnSummaryString.getBytes(StandardCharsets.UTF_8));
     } finally {
       if (criticalPathComputer != null) {
         eventBus.unregister(criticalPathComputer);