protected static void addObjectToBuilders(List<MetricsPacket.Builder> builders, JsonNode object)  {
        MetricsPacket.Builder builder = new MetricsPacket.Builder(ServiceId.toServiceId(object.get("application").textValue()));
        builder.timestamp(Instant.ofEpochSecond(object.get("timestamp").longValue()));
        if (object.has("metrics")) {
            JsonNode metrics = object.get("metrics");
            Iterator<?> keys = metrics.fieldNames();
            while(keys.hasNext()) {
                String key = (String) keys.next();
                builder.putMetric(MetricId.toMetricId(key), metrics.get(key).asLong());
            }
        }
        if (object.has("dimensions")) {
            JsonNode dimensions = object.get("dimensions");
            Iterator<?> keys = dimensions.fieldNames();
            while(keys.hasNext()) {
                String key = (String) keys.next();
                builder.putDimension(DimensionId.toDimensionId(key), dimensions.get(key).asText());
            }
        }
        builder.addConsumers(Set.of(ConsumerId.toConsumerId("Vespa")));
        builders.add(builder);
    }
@Test
    public void testJSONObjectIsCorrectlyConvertedToMetricsPacket() {
        List<MetricsPacket.Builder> builders = new ArrayList<>();
        JsonNode hostLifePacket = generateHostLifePacket();
        NodeMetricGatherer.addObjectToBuilders(builders, hostLifePacket);
        MetricsPacket packet = builders.remove(0).build();

        assertEquals("host_life", packet.service().id);
        assertEquals(123, packet.timestamp().getEpochSecond());
        assertEquals(12L, packet.metrics().get(MetricId.toMetricId("uptime")));
        assertEquals(1L, packet.metrics().get(MetricId.toMetricId("alive")));
        assertEquals(Set.of(ConsumerId.toConsumerId("Vespa")), packet.consumers());
    }