Class HTTPServer

java.lang.Object
io.prometheus.client.exporter.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 = new HTTPServer(1234);
 
 
  • Field Details

  • Constructor Details

  • Method Details

    • shouldUseCompression

      protected static boolean shouldUseCompression(HttpExchange exchange)
    • parseQuery

      protected static Set<String> parseQuery(String query) throws IOException
      Throws:
      IOException
    • start

      private void start(boolean daemon)
      Start an HTTP server by making sure that its background thread inherit proper daemon flag.
    • stop

      public void stop()
      Deprecated.
      renamed to close(), so that the HTTPServer can be used in try-with-resources.
      Stop the HTTP server.
    • close

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

      public int getPort()
      Gets the port number.