private byte[] buildPrometheusForConsumer(String consumer) {
        var snapshot = getSnapshot();
        if (snapshot == null)
            return new byte[0];

        var timestamp = snapshot.getToTime(TimeUnit.MILLISECONDS);
        var builder = new StringBuilder();
        builder.append("# NOTE: THIS API IS NOT INTENDED FOR PUBLIC USE\n");
        var metrics = new ArrayList<PrometheusEntry>();

        for (var tuple : collapseMetrics(snapshot, consumer)) {
            var dims = toPrometheusDimensions(tuple.dim);
            var metricName = prometheusSanitizedName(tuple.key) + "_";
            if (tuple.val instanceof GaugeMetric gauge) {
                metrics.add(new PrometheusEntry(metricName + "max", dims, gauge.getMax()));
                metrics.add(new PrometheusEntry(metricName + "sum", dims, gauge.getSum()));
                metrics.add(new PrometheusEntry(metricName + "count", dims, gauge.getCount()));
                if (gauge.getPercentiles().isPresent()) {
                    for (Tuple2<String, Double> prefixAndValue : gauge.getPercentiles().get()) {
                        metrics.add(new PrometheusEntry(metricName + prefixAndValue.first + "percentile", dims, prefixAndValue.second));
                    }
                }
            } else if (tuple.val instanceof CountMetric count) {
                metrics.add(new PrometheusEntry(metricName + "count", dims, count.getCount()));
            }
        }
        Collections.sort(metrics);
        metrics.forEach(prometheusEntry -> prometheusEntry.appendPrometheusEntry(builder, timestamp));
        return builder.toString().getBytes(UTF_8);
    }
A handler which returns state (health) information from this container instance: Status, metrics and vespa version.

@author Simon Thoresen Hult
container-core/src/main/java/com/yahoo/container/jdisc/state/StateHandler.java