MetricImporterUtils { public static void resolveExtraTagsFromURI(String baseURIPath, String requestURI, Map<String, String> map) { Preconditions.checkNotNull(baseURIPath); Preconditions.checkNotNull(requestURI); String subPath = requestURI.substring(baseURIPath.length()); if (subPath.endsWith("/")) { subPath = subPath.substring(0, subPath.length() - 1); } String[] ss = StringUtils.split(subPath, '/'); if (ss.length % 2 != 0) { throw new IllegalArgumentException("子路径必须有偶数个节"); } for (int i = 0; i < ss.length; i += 2) { map.put(ss[i], ss[i + 1]); } } private  MetricImporterUtils(); static void validExtraTags(Map<String, String> extraTags); static Metric mergeWithExtraTags(Metric metric, Map<String, String> extraTags); static void resolveExtraTagsFromURI(String baseURIPath, String requestURI,
                                               Map<String, String> map); static Map<String, String> resolveExtraTagsFromRequestHeaders(ServerRequest request,
                                                                         Map<String, String> map);  }
@Test public void testResolveExtraTagsFromURI() { Map<String, String> map = new HashMap<>(); MetricImporterUtils.resolveExtraTagsFromURI("a/b/", "a/b/tk1/tv1/tk2/tv2" , map); Assert.assertEquals(2, map.size()); }