class VertxMetricsTags {

    static void parseUriPath(RequestMetric requestMetric, Map<Pattern, String> matchPattern, List<Pattern> ignorePatterns,
            String uri) {
        if (uri == null) {
            return;
        }

        String path = "/" + extractPath(uri);
        path = MULTIPLE_SLASH_PATTERN.matcher(path).replaceAll("/");
        path = TRAILING_SLASH_PATTERN.matcher(path).replaceAll("");

        if (path.isEmpty()) {
            path = "/";
        }
        requestMetric.path = path;
        for (Map.Entry<Pattern, String> mp : matchPattern.entrySet()) {
            requestMetric.path = mp.getKey().matcher(requestMetric.path).replaceAll(mp.getValue());
        }
        requestMetric.pathMatched = !path.equals(requestMetric.path);

        // Compare path against "ignore this path" patterns
        for (Pattern p : ignorePatterns) {
            if (p.matcher(path).matches()) {
                log.debugf("Path %s ignored; matches pattern %s", uri, p.pattern());
                return;
            }
        }
        requestMetric.measure = true;
    }

}