private byte[] getMetricsArray(String metricSetId) throws JsonProcessingException {
        ObjectNode root = jsonMapper.createObjectNode();
        ArrayNode jsonArray = jsonMapper.createArrayNode();
        getPacketsForSnapshot(getSnapshot(), metricSetId, applicationName, timer.currentTimeMillis())
                .forEach(jsonArray::add);
        root.set("metrics", jsonArray);
        return jsonToString(root)
                .getBytes(StandardCharsets.UTF_8);
    }
This handler outputs metrics in a json-like format, consisting of a series of metrics packets.
Each packet is a json object but there is no outer array or object that wraps the packets.
To reduce the amount of output, a packet contains all metrics that share the same set of dimensions.

This handler is not set up by default, but can be added to the applications's services configuration.

This handler is protocol agnostic, so it cannot discriminate between e.g. http request
methods (get/head/post etc.).

Based on {@link StateHandler}.

@author gjoranv
container-core/src/main/java/com/yahoo/container/jdisc/state/MetricsPacketsHandler.java