@Test void testJsonEscaping() { assertThat(MetricImpl.jsonEscape("plain"), is("plain")); assertThat(MetricImpl.jsonEscape("not\bplain\tby\"a\nlong\\shot"), is("not\\bplain\\tby\\\"a\\nlong\\\\shot")); }
static String jsonEscape(String s) { final Matcher m = JSON_ESCAPED_CHARS_REGEX.matcher(s); final StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, JSON_ESCAPED_CHARS_MAP.get(m.group())); } m.appendTail(sb); return sb.toString(); }
MetricImpl implements HelidonMetric { static String jsonEscape(String s) { final Matcher m = JSON_ESCAPED_CHARS_REGEX.matcher(s); final StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, JSON_ESCAPED_CHARS_MAP.get(m.group())); } m.appendTail(sb); return sb.toString(); } }
MetricImpl implements HelidonMetric { static String jsonEscape(String s) { final Matcher m = JSON_ESCAPED_CHARS_REGEX.matcher(s); final StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, JSON_ESCAPED_CHARS_MAP.get(m.group())); } m.appendTail(sb); return sb.toString(); } MetricImpl(String registryType, Metadata metadata); }
MetricImpl implements HelidonMetric { static String jsonEscape(String s) { final Matcher m = JSON_ESCAPED_CHARS_REGEX.matcher(s); final StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, JSON_ESCAPED_CHARS_MAP.get(m.group())); } m.appendTail(sb); return sb.toString(); } MetricImpl(String registryType, Metadata metadata); @Override String getName(); @Override Metadata metadata(); @Override String toString(); @Override void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusNameWithUnits(MetricID metricID); abstract String prometheusValue(); }
MetricImpl implements HelidonMetric { static String jsonEscape(String s) { final Matcher m = JSON_ESCAPED_CHARS_REGEX.matcher(s); final StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, JSON_ESCAPED_CHARS_MAP.get(m.group())); } m.appendTail(sb); return sb.toString(); } MetricImpl(String registryType, Metadata metadata); @Override String getName(); @Override Metadata metadata(); @Override String toString(); @Override void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusNameWithUnits(MetricID metricID); abstract String prometheusValue();  }