Class HTTPServer
java.lang.Object
io.prometheus.metrics.exporter.httpserver.HTTPServer
- All Implemented Interfaces:
Closeable,AutoCloseable
Expose Prometheus metrics using a plain Java HttpServer.
Example Usage:
HTTPServer server = HTTPServer.builder()
.port(9090)
.buildAndStart();
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutorServiceprotected final com.sun.net.httpserver.HttpServer -
Method Summary
Modifier and TypeMethodDescriptionstatic HTTPServer.Builderbuilder()static HTTPServer.Builderbuilder(io.prometheus.metrics.config.PrometheusProperties config) voidclose()Stop the HTTPServer.intgetPort()Gets the port number.voidstop()Stop the HTTP server.
-
Field Details
-
server
protected final com.sun.net.httpserver.HttpServer server -
executorService
-
-
Method Details
-
stop
public void stop()Stop the HTTP server. Same asclose(). -
close
public void close()Stop the HTTPServer. Same asstop().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
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
-
builder
-