GraphiteSanitizer { public static String sanitizeGraphiteMetricSegment(String metricNameSegment) { return DISALLOWED_CHARS.matcher(metricNameSegment .replace('.', ':') .replace(' ', '-') .replace('/', '|') .replace('\\', '|')) .replaceAll("_"); } private  GraphiteSanitizer(); static String sanitizeGraphiteMetricSegment(String metricNameSegment); static final Pattern DISALLOWED_CHARS; }
@Test public void testEncodeForGraphite() throws Exception { Assert.assertEquals("GET-|index:html", GraphiteSanitizer.sanitizeGraphiteMetricSegment("GET /index.html")); }