<commit_before>package io.vertx.ext.prometheus.server;

import io.prometheus.client.CollectorRegistry;
import io.vertx.core.Closeable;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.net.SocketAddress;
import io.vertx.ext.web.Router;
import org.jetbrains.annotations.NotNull;

import java.util.function.Function;

public enum MetricsServer {
  ;
  private static final @NotNull Logger log = LoggerFactory.getLogger(MetricsServer.class);

  public static @NotNull Function<CollectorRegistry, Function<SocketAddress, Closeable>> create(@NotNull Vertx vertx) {
    final HttpServer server = vertx.createHttpServer();
    final Router router = Router.router(vertx);
    return registry -> {
      router.route("/metrics").handler(new MetricsHandler(registry));
      return address -> {
        server.requestHandler(router::accept).listen(address.port(), address.host());
        log.info("Prometheus metrics server started at " + address);
        return server::close;
      };
    };
  }
}
<commit_msg>compress exposed metrics #13 (cherry picked from commit 1f89830)<commit_after>package io.vertx.ext.prometheus.server;

import io.prometheus.client.CollectorRegistry;
import io.vertx.core.Closeable;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.net.SocketAddress;
import io.vertx.ext.web.Router;
import org.jetbrains.annotations.NotNull;

import java.util.function.Function;

public enum MetricsServer {
  ;
  private static final @NotNull Logger log = LoggerFactory.getLogger(MetricsServer.class);

  public static @NotNull Function<CollectorRegistry, Function<SocketAddress, Closeable>> create(@NotNull Vertx vertx) {
    final HttpServerOptions options = new HttpServerOptions().setCompressionSupported(true).setCompressionLevel(6);
    final HttpServer server = vertx.createHttpServer(options);
    final Router router = Router.router(vertx);
    return registry -> {
      router.route("/metrics").handler(new MetricsHandler(registry));
      return address -> {
        server.requestHandler(router::accept).listen(address.port(), address.host());
        log.info("Prometheus metrics server started at " + address);
        return server::close;
      };
    };
  }
}

{'fraction_non_alphanumeric': 0.11530653674380836, 'fraction_numerical': 0.0036540803897685747, 'mean_word_length': 4.664367816091954, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '7320323', 'n_tokens_mistral': 723, 'n_tokens_neox': 706, 'n_words': 145}