<commit_before>package de.synyx.metrics.servlet.listener;

import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.ScheduledReporter;
import com.codahale.metrics.graphite.Graphite;
import com.codahale.metrics.graphite.GraphiteReporter;

import java.net.InetSocketAddress;
import java.net.URI;
import java.util.Map;

/**
 * Date: 31.07.2014
 * Time: 14:40
 */
public final class MetricReportHandlerGraphite extends MetricReportHandler {

    protected final String scheme () {
        return "graphite";
    }

    @Override
    protected final ScheduledReporter reporter (MetricRegistry registry, URI uri) {
        Map<String, String> parameters = parameters (uri.getQuery ());

        Graphite graphite = new Graphite (new InetSocketAddress (uri.getHost (), uri.getPort ()));

        GraphiteReporter reporter = GraphiteReporter.forRegistry (registry)
                                            .convertRatesTo     (timeunit (or (parameters.get ("rate"),    "ms")))
                                            .convertDurationsTo (timeunit (or (parameters.get ("duration"), "s")))
                                                .filter (MetricFilter.ALL)
                                                    .build (graphite);

        return start (reporter, parameters.get ("refresh"));
    }

}<commit_msg>added prefix parameter to the uri scheme<commit_after>package de.synyx.metrics.servlet.listener;

import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.ScheduledReporter;
import com.codahale.metrics.graphite.Graphite;
import com.codahale.metrics.graphite.GraphiteReporter;

import java.net.InetSocketAddress;
import java.net.URI;
import java.util.Map;

/**
 * Date: 31.07.2014
 * Time: 14:40
 */
public final class MetricReportHandlerGraphite extends MetricReportHandler {

    protected final String scheme () {
        return "graphite";
    }

    @Override
    protected final ScheduledReporter reporter (MetricRegistry registry, URI uri) {
        Map<String, String> parameters = parameters (uri.getQuery ());

        Graphite graphite = new Graphite (new InetSocketAddress (uri.getHost (), uri.getPort ()));

        GraphiteReporter reporter = GraphiteReporter.forRegistry (registry)
                                            .prefixedWith       (             (parameters.get ("prefix")        ))
                                            .convertRatesTo     (timeunit (or (parameters.get ("rate"),    "ms")))
                                            .convertDurationsTo (timeunit (or (parameters.get ("duration"), "s")))
                                                .filter (MetricFilter.ALL)
                                                    .build (graphite);

        return start (reporter, parameters.get ("refresh"));
    }

}
{'fraction_non_alphanumeric': 0.10048510048510048, 'fraction_numerical': 0.008316008316008316, 'mean_word_length': 2.21850613154961, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2375105', 'n_tokens_mistral': 750, 'n_tokens_neox': 714, 'n_words': 171}