public List<MetricsPacket> getMetrics(List<VespaService> services, Instant startTime) {
        MetricsPacket.Builder[] builderArray = getMetricsBuildersAsArray(services, startTime, null);
        List<MetricsPacket> metricsPackets = new ArrayList<>(builderArray.length);
        for (int i = 0; i < builderArray.length; i++) {
            metricsPackets.add(builderArray[i].build());
            builderArray[i] = null; // Set null to be able to GC the builder when packet has been created
        }
        return metricsPackets;
    }
@Test
    public void system_metrics_are_added() {
        VespaService service0 = testServices.get(0);
        Metrics oldSystemMetrics = service0.getSystemMetrics();

        service0.getSystemMetrics().add(new Metric(toMetricId("cpu"), 1));

        List<MetricsPacket> packets = metricsManager.getMetrics(testServices, Instant.EPOCH);
        assertEquals(3, packets.size());

        MetricsPacket systemPacket = packets.get(0); // system metrics are added before other metrics
        assertEquals(1, systemPacket.metrics().get(toMetricId("cpu")));
        assertEquals("system", systemPacket.dimensions().get(toDimensionId("metrictype")));

        service0.setSystemMetrics(oldSystemMetrics);
    }