<commit_before>package com.avast.metrics.dropwizard.formatting;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Graphite/StatsD formatter.
 * <p>
 * https://prometheus.io/docs/instrumenting/exposition_formats/
 * https://prometheus.io/docs/concepts/data_model/
 * <metric name>{<label name>=<label value>, ...}
 */
public class PrometheusFormatter implements Formatter {
    private static final String SEPARATOR_NAME_PARTS = "_";
    private static final String SEPARATOR_NAME_VALUE = " ";
    private static final String SEPARATOR_METRICS = "\n";

    @Override
    public String nameSeparator() {
        return SEPARATOR_NAME_PARTS;
    }

    @Override
    public String sanitizeName(String namePart) {
        StringBuilder result = new StringBuilder(namePart.length());

        for (int i = 0; i < namePart.length(); ++i) {
            char c = namePart.charAt(i);

            // Regexp for full name is [a-zA-Z_:][a-zA-Z0-9_:]*
            // '_' is separator of parts
            if (c >= 'a' && c <= 'z'
                    || c >= 'A' && c <= 'Z'<commit_msg>Javadoc fixes.<commit_after>package com.avast.metrics.dropwizard.formatting;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Graphite/StatsD formatter.
 * <p>
 * https://prometheus.io/docs/instrumenting/exposition_formats/
 * https://prometheus.io/docs/concepts/data_model/
 * &lt;metric name&gt; value
 * &lt;metric name&gt;{&lt;label name&gt;=&lt;label value&gt;, ...} value
 */
public class PrometheusFormatter implements Formatter {
    private static final String SEPARATOR_NAME_PARTS = "_";
    private static final String SEPARATOR_NAME_VALUE = " ";
    private static final String SEPARATOR_METRICS = "\n";

    @Override
    public String nameSeparator() {
        return SEPARATOR_NAME_PARTS;
    }

    @Override
    public String sanitizeName(String namePart) {
        StringBuilder result = new StringBuilder(namePart.length());

        for (int i = 0; i < namePart.length(); ++i) {
            char c = namePart.charAt(i);

            // Regexp for full name is [a-zA-Z_:][a-zA-Z0-9_:]*
            // '_' is separator of parts
            if (c >= 'a' && c <= 'z'
                    || c >= 'A' && c <= 'Z'
{'fraction_non_alphanumeric': 0.13664596273291926, 'fraction_numerical': 0.0026619343389529724, 'mean_word_length': 2.8026981450252952, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2566302', 'n_tokens_mistral': 735, 'n_tokens_neox': 704, 'n_words': 164}