private static List<MetricsPacket.Builder> toServicePackets(GenericService service) {
        List<MetricsPacket.Builder> packets = new ArrayList<>();
        if (service.metrics == null || service.metrics.isEmpty())
            return List.of(newServicePacket(service));

        for (var genericMetrics : service.metrics) {
            var packet = newServicePacket(service);
            addMetrics(genericMetrics, packet);
            packets.add(packet);
        }
        return packets;

    }
Utilities for converting between metrics packets and the generic json format.

@author gjoranv
metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/model/json/GenericJsonUtil.java