@Override
    public String filterCharacters(String metricName) {
        char[] chars = null;
        final int strLen = metricName.length();
        int pos = 0;

        for (int i = 0; i < strLen; i++) {
            final char c = metricName.charAt(i);
            switch (c) {
                case '.':
                    if (chars == null) {
                        chars = metricName.toCharArray();
                    }
                    chars[pos++] = '-';
                    break;
                case '"':
                    if (chars == null) {
                        chars = metricName.toCharArray();
                    }
                    break;

                default:
                    if (chars != null) {
                        chars[pos] = c;
                    }
                    pos++;
            }
        }

        return chars == null ? metricName : new String(chars, 0, pos);
    }
@Test
    void testInvalidCharacterReplacement() {
        ScheduledDropwizardReporter reporter =
                new ScheduledDropwizardReporter() {
                    @Override
                    public ScheduledReporter getReporter(MetricConfig config) {
                        return null;
                    }
                };

        assertThat(reporter.filterCharacters("abc")).isEqualTo("abc");
        assertThat(reporter.filterCharacters("a..b.c.")).isEqualTo("a--b-c-");
        assertThat(reporter.filterCharacters("a\"b.c")).isEqualTo("ab-c");
    }