private String escapedLabelValue(String labelValue) {
        var builder = new StringBuilder();
        for (int i = 0; i < labelValue.length(); i++) {
            var c = labelValue.charAt(i);
            switch (c) {
                case '\n':
                    builder.append("\\n");
                    break;
                case '\\':
                case '"':
                    builder.append("\\")
                           .append(c);
                    break;
                default:
                    builder.append(c);
            }
        }
        return builder.toString();
    }
Produces a flat list of metric entries from a snapshot (which organizes metrics by dimensions)
container-core/src/main/java/com/yahoo/container/jdisc/state/StateHandler.java