java.lang.Object
io.prometheus.metrics.exporter.httpserver.HTTPServer
All Implemented Interfaces:
Closeable, AutoCloseable

public class HTTPServer extends Object implements Closeable
Expose Prometheus metrics using a plain Java HttpServer.

Example Usage:


 HTTPServer server = HTTPServer.builder()
     .port(9090)
     .buildAndStart();
 
  • Field Details

    • server

      protected final com.sun.net.httpserver.HttpServer server
    • executorService

      protected final ExecutorService executorService
  • Method Details

    • stop

      public void stop()
      Stop the HTTP server. Same as close().
    • close

      public void close()
      Stop the HTTPServer. Same as stop().
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getPort

      public int getPort()
      Gets the port number. This is useful if you did not specify a port and the server picked a free port automatically.
    • builder

      public static HTTPServer.Builder builder()
    • builder

      public static HTTPServer.Builder builder(io.prometheus.metrics.config.PrometheusProperties config)