Class HTTPServer
java.lang.Object
io.prometheus.client.exporter.HTTPServer
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWe keep the original constructors ofHTTPServerfor compatibility, but new configuration parameters likesampleNameFiltermust be configured using the Builder.static classHandles Metrics collections from the given registry. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutorServiceprotected final com.sun.net.httpserver.HttpServer -
Constructor Summary
ConstructorsConstructorDescriptionHTTPServer(int port) Start an HTTP server serving the default Prometheus registry using non-daemon threads.HTTPServer(int port, boolean daemon) Start an HTTP server serving the default Prometheus registry.HTTPServer(com.sun.net.httpserver.HttpServer httpServer, CollectorRegistry registry, boolean daemon) Start an HTTP server serving Prometheus metrics from the given registry using the givenHttpServer.HTTPServer(String host, int port) Start an HTTP server serving the default Prometheus registry using non-daemon threads.HTTPServer(String host, int port, boolean daemon) Start an HTTP server serving the default Prometheus registry.HTTPServer(InetSocketAddress addr, CollectorRegistry registry) Start an HTTP server serving Prometheus metrics from the given registry using non-daemon threads.HTTPServer(InetSocketAddress addr, CollectorRegistry registry, boolean daemon) Start an HTTP server serving Prometheus metrics from the given registry. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stop the HTTPServer.intgetPort()Gets the port number.parseQuery(String query) protected static booleanshouldUseCompression(com.sun.net.httpserver.HttpExchange exchange) voidstop()Deprecated.renamed to close(), so that the HTTPServer can be used in try-with-resources.
-
Field Details
-
server
protected final com.sun.net.httpserver.HttpServer server -
executorService
-
-
Constructor Details
-
HTTPServer
public HTTPServer(com.sun.net.httpserver.HttpServer httpServer, CollectorRegistry registry, boolean daemon) throws IOException Start an HTTP server serving Prometheus metrics from the given registry using the givenHttpServer. ThehttpServeris expected to already be bound to an address- Throws:
IOException
-
HTTPServer
public HTTPServer(InetSocketAddress addr, CollectorRegistry registry, boolean daemon) throws IOException Start an HTTP server serving Prometheus metrics from the given registry.- Throws:
IOException
-
HTTPServer
Start an HTTP server serving Prometheus metrics from the given registry using non-daemon threads.- Throws:
IOException
-
HTTPServer
Start an HTTP server serving the default Prometheus registry.- Throws:
IOException
-
HTTPServer
Start an HTTP server serving the default Prometheus registry using non-daemon threads.- Throws:
IOException
-
HTTPServer
Start an HTTP server serving the default Prometheus registry.- Throws:
IOException
-
HTTPServer
Start an HTTP server serving the default Prometheus registry using non-daemon threads.- Throws:
IOException
-
-
Method Details
-
shouldUseCompression
protected static boolean shouldUseCompression(com.sun.net.httpserver.HttpExchange exchange) -
parseQuery
- Throws:
IOException
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getPort
public int getPort()Gets the port number.
-