private static Map<DimensionId, String> parseDimensions(JsonParser parser,
                                                            Map<Set<Dimension>, Map<DimensionId, String>> uniqueDimensions) throws IOException {

        Set<Dimension> dimensions = new HashSet<>();

        for (parser.nextToken(); parser.currentToken() != JsonToken.END_OBJECT; parser.nextToken()) {
            String fieldName = parser.currentName();
            JsonToken token = parser.nextToken();

            if (token == JsonToken.VALUE_STRING){
                String value = parser.getValueAsString();
                dimensions.add(Dimension.of(fieldName, value));
            } else if (token == JsonToken.VALUE_NULL) {
                // TODO Should log a warning if this happens
            } else {
                throw new IllegalArgumentException("Dimension '" + fieldName + "' must be a string");
            }
        }
        return uniqueDimensions.computeIfAbsent(dimensions,
                                                key -> dimensions.stream().collect(Collectors.toUnmodifiableMap(
                                                        dim -> toDimensionId(dim.id), dim -> dim.value)));
    }
Fetch metrics for a given vespa service

@author Jo Kristian Bergum
metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/MetricsParser.java