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.private static class(package private) static class -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionHTTPServer(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(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.privateHTTPServer(ExecutorService executorService, HttpServer httpServer, CollectorRegistry registry, boolean daemon, Supplier<Predicate<String>> sampleNameFilterSupplier, Authenticator authenticator) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stop the HTTPServer.intgetPort()Gets the port number.parseQuery(String query) protected static booleanshouldUseCompression(HttpExchange exchange) private voidstart(boolean daemon) Start an HTTP server by making sure that its background thread inherit proper daemon flag.voidstop()Deprecated.renamed to close(), so that the HTTPServer can be used in try-with-resources.
-
Field Details
-
server
-
executorService
-
-
Constructor Details
-
HTTPServer
public 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
-
HTTPServer
private HTTPServer(ExecutorService executorService, HttpServer httpServer, CollectorRegistry registry, boolean daemon, Supplier<Predicate<String>> sampleNameFilterSupplier, Authenticator authenticator)
-
-
Method Details
-
shouldUseCompression
-
parseQuery
- 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getPort
public int getPort()Gets the port number.
-